Video Tutorial Library:

Visual Basic 301 - Visual Basic 9.0 Language Enhancements :

VB301_02_01 - Local Type Inference

Tags: VB , Language , Experienced , 2008
In this video we'll talk about local type inference, also known as implicitly typed local variables.  This introduces an easy way to create a variable without having to know the type ... but allowing the initializer to dictate the data type.  When we work with LINQ, many times it may not be very clear what a given linq query is returning, and so local type inference allows us to say "we don't really care what it is, let VB figure it out."  Microsoft suggests that you use this technique when working with LINQ 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 this technique only works for the local scope.  You can't return or reference a variable created with this technique outside of the scope of a local method.

Downloads:

Sign up today to access downloads.
VB301_02_01 - Local Type Inference
Duration: 9 Minutes, 40 Seconds
Size: 8.06M
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.