Possible Duplicate:
Resharper: vars
Is there a reason that resharper suggests var thing1 = 5
as opposed to int thing1 = 5
? It just seems that they mean the exact same thing except that var is harder/less comprehensible to a human reader. I would be curious to know if there is a difference in the way that the compiler interprets them, or if its just syntactic sugar.
No, the generated IL will be exactly the same.
I suspect if you take up Resharper's suggestion, it will also "suggest" going the other way - IIRC the default is to always offer the ability to change in either direction. You can change what it suggests within the options though.
Usage of the 'var' keyword tends to be controversial. The 'authoritative' reference for this debate is http://blogs.msdn.com/b/ericlippert/archive/2011/04/20/uses-and-misuses-of-implicit-typing.aspx
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