Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use of 'var' in C#
Message
De
30/04/2010 14:15:47
 
 
À
30/04/2010 13:14:42
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01462533
Message ID:
01462565
Vues:
61
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"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform