Video Tutorial Library:

C# 301 - C# 3.0 Language Enhancements :

CS301_02_01 - Local Type Inference (var keyword)

Tags: C# , Language , 2008
In this video we'll talk about local type inference, also known as implicitly
typed local variables.  This introduces the var keyword to C# 3.0, and it is
used basically as an easy way to create a variable without having to know
the type.  When we work with LINQ, many times it may not be very clear what
a given linq query is returning, and so the var keyword allows us to say
"we don't really care what it is, let C# figure it out."  Now, microsoft
suggests that you use the var keyword to make development easier.  Some
authors I've read insist that you should use it as a temporary measure until
you can figure out the exact return type ... one technique would be to set
a break point and use the debugging tools to figure out what the actual type
is.  Whichever you decide is up to you, but the one thing to keep in mind
is that the var keyword only works for the local scope.  You can't return or
reference a variable created with var outside of the scope of a local method.

Downloads:

Sign up today to access downloads.
CS301_02_01 - Local Type Inference (var Keyword)
Duration: 12 Minutes, 48 Seconds
Size: 14.04M
Recorded Using: Visual Studio 2008 (all versions)

Get Free Videos via Email

Sign up for our newsletter and receive links to free videos and more.

Subscribe

We don't rent/sell/or commit other evil deeds with your email address. See our Privacy Policy.