Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of 'var' in C#
Message
From
30/04/2010 14:15:47
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01462533
Message ID:
01462565
Views:
62
That's too funny that they specifically write "does not mean variant"..

So I guess if it was a variant, the compiler wouldn't assign it the most appropriate type then. :-)

But, I think I see the difference.. if we have a variant (which I have not used in forever) we can say

variant varTest = "Hey";
varTest = 9;

That would work, correct?

But in the case of c#,

var varTest = "Hey"; // varTest would by type string

varTest = 9; // compiler error.


>"It is important to understand that the var keyword does not mean “variant” and does not indicate that the variable is loosely typed, or late-bound. It just means that the compiler determines and assigns the most appropriate type"
Previous
Reply
Map
View

Click here to load this message in the networking platform