Let's say that NORMALLY, if i
is a local variable, it will be saved on the stack. The abstract VM of .NET is a stack based one.
I'll add that on Intel/AMD i
won't be saved that way :-) Intel/AMD are little endian. So it will be 00000001 00000000 00000000 00000000
I'm mixing it a little... Now... the IL language and the .NET abstract VM are "pure" stack based, so there is a stack :-) (but there are no registers, so "pure") (I hope you know what a stack is). When the code is JITted to machine code for the computer you are using, probably i
will be put in a register or on the stack.
Note that in general it's wrong wrong wrong to say that value types (or non-reference types, if you want to include managed/unmanaged pointers/references) are saved on the stack and/or in registers. They are saved where they are saved. For example value types member of a class are saved with(in) the class (so normally in the heap). Value types in yield functions, in async functions, in "normal" methods but being referenced by "closure type" anonymous functions are normally saved somewhere in the heap. But all these are reference implementations details.