Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of 'var' in C#
Message
From
01/05/2010 08:52:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01462533
Message ID:
01462630
Views:
49
>>>>>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).
>
<?xml version="1.0" encoding="utf-8" ?>
><CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
>  <CodeSnippet Format="1.0.0">
>    <Header>
>      <Title>dtnrea</Title>
>      <Shortcut>dtnrea</Shortcut>
>      <Description>Code snippet for DataTableNewRowEventArgs</Description>
>      <Author>Viv</Author>
>      <SnippetTypes>
>        <SnippetType>Expansion</SnippetType>
>      </SnippetTypes>
>    </Header>
>    <Snippet>
>      <Code Language="csharp">
>        <![CDATA[DataTableNewRowEventArgs]]>
>      </Code>
>    </Snippet>
>  </CodeSnippet>
></CodeSnippets>
(g)

Nice Viv,
Now do that for all the classes that exist plus those that might be introduced as new:) Actually LinqPad have tricks with snippets too and much beyod that:)
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform