Difference between “var” and “object” in C#

前端 未结 6 687
生来不讨喜
生来不讨喜 2020-11-29 12:06

Is the var type an equivalent to Variant in VB? When object can accept any datatype, what is the difference between those two?

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 12:36

    The other answers are right on, I'd just like to add that you can actually put your cursor on the 'var' keyword and hit F12 to jump to the inferred type declaration.

提交回复
热议问题