【发布时间】:2012-05-21 07:25:42
【问题描述】:
可能重复:
What's the point of the var keyword?
What advantages does using var have over the explicit type in C#?
我总是看到其他人编写如下代码:
var smtp = new SmtpClient();
但为什么在这种情况下使用var 而不是SmtpClient?我总是使用
SmtpClient smtp = new SmtpClient();
var 效率更高吗?为什么使用var 而不是实际的变量类型?我错过了什么吗?
【问题讨论】:
-
@MattBall Lol 和 那是也是重复的