The var keyword is a new keyword in Dot net Framework 3.5 that can infer its data type from the resulting set. Var keyword
For instance, look at the following examples:
var one = 1; //infers an int
var two = "2"; // infers a string
var three = from c in Customers select c; //infers IQueryable<Customer>
var four = customers.FirstOrDefault(); //infers Customer reference
This means full intellisense is available in VS 2008, as long as the compiler can infer the type. The following results in a compile error:
var five = null;
because the compiler couldn't infer the type of the variable from null. “Var” is NOT a variant, everything is known by the compiler at compile-time.
var keyword can be used in place of the type name when performing local variable declarations.
Actually, "var" only tell the compiler to replace it with the type name by infering the type from the value we assign while initializing the variable.
Revision number 4, Tuesday, January 20, 2009 5:13:34 PM by vik20000in
You must Login to comment.
|
Thu, Nov 6, 2008 5:36 PM
by syed.tayyab.ali
|
Really very good short tutorial on var keyword.
|
|
Mon, Jan 26, 2009 6:15 PM
by atarikg
|
Nice explanations for Novice people. thanks.
|
|
Wed, Jan 28, 2009 1:00 AM
by rami_nassar
|
weake... need formating
|
|
Wed, May 6, 2009 9:55 AM
by idgetman05
|
Needs some mroe work got the basic idea but needs more examples maybe some more advanced examples to help explain bettter
|
|
Tue, Jun 2, 2009 2:50 AM
by Muhammad Ejaz
|
Good work keep it up.
|
|
Thu, Jun 25, 2009 3:35 PM
by srinivaskotra
|
good one
|
|
Fri, Oct 30, 2009 1:31 AM
by yrb.yogi
|
I have never used this one...but try today..
Good article.!
|
Revision #12
Mon, Feb 16, 2009 4:03 PM
by
|
Visual Studio 2008
Visual Studio 2008is theversion of Visual Studio which comes with the .NET Framework 3.5. It was released to MSDN subscribers on 19 November 2007 alongside the.NET Framework 3.5. Visual Studio 2008 can target developmentin .NET Framework versions 2.0, 3.0
|
Revision #5
Sat, Feb 27, 2010 8:50 AM
by
|
Deployment
Deployment continues to get easier, but there's still a few gotchas here and there. Check out these choice articles for you deployment questions. Web Deployment Projects- Fritz Onion's most excellent article on Web Deployment Projects. He goes into
|
Revision #6
Thu, Aug 23, 2012 10:10 AM
by
|
HTML
Visual Studio 2008 adds dramatically improved HTML and CSS Designer Support. From ScottGu: "VS 2008 now uses the same web designer that ships with Microsoft's new Expression Web product. In addition to providing lots of new functionality, you'll
|
Revision #2
Mon, Aug 9, 2010 5:16 PM
by
|
Speed Up Visual Studio 2008
1- Disable toolbox populate from the mainmenu open Tools->Options Select the general tab under Windows Forms Designer Set AutoToolBoxPopulate to false. Although the setting is under Windows Forms Designer, it is just as effective for ASP.Net developers
|