Ok, I read everything that I can find on var, and I'm sure I have a pen on their basic behaviors and type of output. I've always been a big proponent of explicit types, so var annoys me a bit when I read the code. Therefore, I have a couple of questions regarding the use of memory and the behavior of a variable declared with var during the life cycle of this variable in memory.
Since var is the output for an explicit or anonymous type, whether its memory would be allocated in the same place that its corresponding type would be or would be universal, created on the heap and accessible as if it were an object. As an example:
int i = 5;
var i = 5;
Is the declared var a constant type after it is initialized, or can it be adjusted? I ask about this because I cannot find in the documentation that indicates this, and I just read something in this SO @Eric Lippert question :
a variable is a storage location, content change
By testing the following code, I see an implicit conversion exception even at the IDE level. At this point, I have no experience with LINQ to perform a similar test with respect to anonymous types. Do they follow the same behavior? Will the IDE recognize type mismatch at design time, or will such code receive an exception at run time?
var i = 5;
i = "Steve";
, - , , , var ? , , , , , .
EDIT: , , , ( ). , , , , .