Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use of 'var' in C#
Message
De
30/04/2010 18:20:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01462533
Message ID:
01462602
Vues:
58
>>>What's the benefit of
>>>
>>>
>>>var customer = new Customer();
>>>
>>>
>>>as opposed to
>>>
>>>
>>>Customer customer = new Customer();
>>>
>>
>>Most of the time the type can be inferred from the right side. In those cases var is a keyword meaning the inferred type. One big advantage is that if sometimes you are unsure about the type (but it can be inferred) then you use "var" then hover your cursor on var to see the inferred type. You are free to type the type yourself or let it be inferred.
>>Cetin
>
>I read an article in MSDN Magazine the other day about the new version of VB. There is a ton of stuff like that, not only type inference but elimination of some minor annoyances like always having to use continuation characters. The author, who is on the VB team at Microsoft, said they listened to their customers who have been asking them to let the compiler "just figure it out."

Yes they are listening to:) I am hoping even one day the editor might come up to LinqPad's level
(For Example type dtnrea to get to DataTableNewRowEventArgs or select and execute selection).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform