Possible Duplicate:
What's the point of the var keyword?
What advantages does using var have over the explicit type in C#?
I always see other people producing code like:
var smtp = new SmtpClient();
But why use var instead of SmtpClient in this case? I ALWAYS use
SmtpClient smtp = new SmtpClient();
Is var more efficient? Why use var instead of the actual variable type? Am I missing something?
Imagine this.
varis useful for things like that.Much simpler. The point of
varis the same asautoin C++ 11, the compiler knows the type so why must we repeat ourselves so much. I personally usevarrarely, but only for lengthly declarations. It’s just syntactic sugar.