var keyword runtime or compile time?

前端 未结 3 564
闹比i
闹比i 2020-12-05 16:45

var keyword gets the type at the runtime or compile time?

or depends?

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 17:09

    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

提交回复
热议问题