Click here to Skip to main content
15,886,823 members
Home / Discussions / C#
   

C#

 
AnswerRe: What options do I have for reading data from an excel spreadsheet, and what are the limitations of each? Pin
SledgeHammer0129-Jul-14 18:09
SledgeHammer0129-Jul-14 18:09 
GeneralRe: What options do I have for reading data from an excel spreadsheet, and what are the limitations of each? Pin
Mycroft Holmes29-Jul-14 19:18
professionalMycroft Holmes29-Jul-14 19:18 
AnswerRe: What options do I have for reading data from an excel spreadsheet, and what are the limitations of each? Pin
Bernhard Hiller29-Jul-14 20:34
Bernhard Hiller29-Jul-14 20:34 
AnswerRe: What options do I have for reading data from an excel spreadsheet, and what are the limitations of each? Pin
Richard Deeming30-Jul-14 1:33
mveRichard Deeming30-Jul-14 1:33 
AnswerRe: What options do I have for reading data from an excel spreadsheet, and what are the limitations of each? Pin
jschell31-Jul-14 9:29
jschell31-Jul-14 9:29 
Questionstack / heap assignment under the hood Pin
taking_liberties29-Jul-14 4:06
taking_liberties29-Jul-14 4:06 
AnswerRe: stack / heap assignment under the hood Pin
Simon_Whale29-Jul-14 4:29
Simon_Whale29-Jul-14 4:29 
GeneralRe: stack / heap assignment under the hood Pin
harold aptroot29-Jul-14 4:52
harold aptroot29-Jul-14 4:52 
taking_liberties wrote:
ok, MyClass is a ref type, I'd better put it on the heap
MyInt derives from System.ValueType and it's a local variable, I'd better put it on the stack.
Obviously it can't do that, since not all instances of value types always go on the heap (for example, MyClass.x).
The MSIL tells it what to do. Your example code was unfortunately a poor example, because ints are magic and therefore don't show how code with value types compiles in general.
So I changed the code a bit.
MSIL
.maxstack 2
.locals init (
    [0] class Test.Program/MyClass mc,
    [1] valuetype Test.Vec2 v
)

IL_0000: nop
IL_0001: newobj instance void Test.Program/MyClass::.ctor()
IL_0006: stloc.0
IL_0007: ldloca.s v
IL_0009: initobj Test.Vec2
IL_000f: ldloc.0
IL_0010: ldloc.1
IL_0011: stfld valuetype Test.Vec2 Test.Program/MyClass::x
IL_0016: ret

This should make some things clear. A reference to a MyClass and an instance of Vec2 both conceptually go on the stack (that is, they are locals). The instance of MyClass is "newobj"-ed, while the instance of Vec2 is "initobj"-ed. newobj allocates an object and pushed a reference to it on the evaluation stack - not "the stack", this is just the stack that MSIL conceptually uses because it's a stack language, that's really just to connect instructions implicitly to their operands. "initobj" takes an address and zeroes out the fields of the value type there in-place.
When the JIT compiler gets its hands on this, it could do anything that preserves the semantics, and what it actually does, depends. In debug mode (ie ran in a debugger and Suppress JIT Optimizations is ON (default)) it really likes The Stack (the real deal, nothing conceptual at this point) and all locals are always written back to the stack even when they are then immediately read back. In optimized mode, most temporaries only appear in registers, and locals are often completely enregistered as well (unless it doesn't fit or they have to be preserved across a call). It seems to have a tendency to put non-primitive value types on the stack though. (other JIT compilers may behave differently, YMMV)
GeneralRe: stack / heap assignment under the hood Pin
taking_liberties29-Jul-14 6:42
taking_liberties29-Jul-14 6:42 
AnswerRe: stack / heap assignment under the hood Pin
OriginalGriff29-Jul-14 5:07
mveOriginalGriff29-Jul-14 5:07 
GeneralRe: stack / heap assignment under the hood Pin
Rob Philpott29-Jul-14 6:19
Rob Philpott29-Jul-14 6:19 
GeneralRe: stack / heap assignment under the hood Pin
OriginalGriff29-Jul-14 6:25
mveOriginalGriff29-Jul-14 6:25 
GeneralNot enough storage is available to complete this operation Pin
Tal Humy29-Jul-14 3:20
Tal Humy29-Jul-14 3:20 
QuestionRe: Not enough storage is available to complete this operation Pin
Eddy Vluggen29-Jul-14 6:24
professionalEddy Vluggen29-Jul-14 6:24 
GeneralRe: Not enough storage is available to complete this operation Pin
Bernhard Hiller29-Jul-14 20:43
Bernhard Hiller29-Jul-14 20:43 
QuestionOData 4 $InLineCount Pin
JoelPark28-Jul-14 10:58
JoelPark28-Jul-14 10:58 
AnswerRe: OData 4 $InLineCount Pin
OriginalGriff28-Jul-14 21:38
mveOriginalGriff28-Jul-14 21:38 
AnswerRe: OData 4 $InLineCount Pin
Kornfeld Eliyahu Peter28-Jul-14 22:20
professionalKornfeld Eliyahu Peter28-Jul-14 22:20 
GeneralRe: OData 4 $InLineCount Pin
JoelPark29-Jul-14 3:37
JoelPark29-Jul-14 3:37 
QuestionHow to retain Dropdownlist value after selectedindexchanged and postback?? Pin
lan160727-Jul-14 14:07
lan160727-Jul-14 14:07 
AnswerRe: How to retain Dropdownlist value after selectedindexchanged and postback?? Pin
Ron Nicholson28-Jul-14 4:48
professionalRon Nicholson28-Jul-14 4:48 
AnswerRe: How to retain Dropdownlist value after selectedindexchanged and postback?? Pin
Member 924543128-Jul-14 8:21
Member 924543128-Jul-14 8:21 
GeneralRe: How to retain Dropdownlist value after selectedindexchanged and postback?? Pin
lan160729-Jul-14 14:01
lan160729-Jul-14 14:01 
GeneralRe: How to retain Dropdownlist value after selectedindexchanged and postback?? Pin
Member 924543130-Jul-14 0:38
Member 924543130-Jul-14 0:38 
GeneralRe: How to retain Dropdownlist value after selectedindexchanged and postback?? Pin
lan160730-Jul-14 19:35
lan160730-Jul-14 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.