Var keyword runtime or compile time?

Does var keyword get type at runtime or compile time?

or depends?

+5
source share
3 answers

Normal and simple: compilation time

varnot a type. The actual type is computed at compile time.

varvariables are also known as Implicitly Typed Local Variables (C # Programming Guide)

+15
source

Type var gets the value compile time.

Var is an implicitly typed local variable that is strongly typed in the same way as if you yourself declared the type, but the compiler determines the type

var i = 10; // implicitly typed
int i = 10; //explicitly typed

http://msdn.microsoft.com/en-us/library/bb383973.aspx

+4

The var keyword is implicitly typed. This means that it is strongly typed, but the compiler determines the type.

+1
source

All Articles