var keyword gets the type at the runtime or compile time?
or depends?
Plain and simple: compile time
var
isn't a type. The actual type is figured out at compile-time.
var
variables are also known as Implicitly Typed Local Variables (C# Programming Guide)
var type gets at compile time
.
Var is an implicitly typed local variable is strongly typed just as if you had declared the type yourself, 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
The var keyword is implicitly typed. This means that it is strongly typed, but the compiler determines the type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With