What's New in the Visual Basic Language

Visual Basic 2008 introduces new language features, including local type inference, object initializers, anonymous types, and extension methods. These features serve as support for an important new feature, Language-Integrated Query (LINQ), but they are also useful individually.

This topic introduces the new features and provides links to additional information about them.

Feature

Description

Queries (Visual Basic)

In this topic, you can find more information about queries, including information about these keywords:

  • From

  • Where

  • Select

  • Order By

  • Join

  • Group By

  • Skip

  • Take

  • Distinct

XML in Visual Basic

You can now include XML as first-class data types in your Visual Basic code, making it fast and easy to create, transform, modify, and query XML.

Local Type Inference

By using local type inference (also referred to as implicit typing), the compiler determines the data types of local variables based on the values that are used to initialize them.

Object Initializers: Named and Anonymous Types

By using object initializers, you can initialize a complex data object in an expression, without an explicit call to a constructor.

Anonymous Types

The anonymous types feature enables you to create instances of a new data type without first writing the definition of the class. Instead, the compiler creates the data type definition based on the properties you specify when you declare the instance.

Extension Methods (Visual Basic)

Extension methods enable you to add methods to a data type from outside the type. The methods can be invoked as if they were ordinary instance methods of the data type

Lambda Expressions

A lambda expression is a function without a name that can be used wherever a delegate type is valid.

If Operator

The If operator uses short-circuit evaluation to conditionally return one of two values. It can be called with three arguments or with two arguments.

Partial Methods

Partial methods enable developers to insert custom logic into code. A partial method is defined in a partial class, and any developer who uses the class can specify the desired behavior for the method.

Nullable Value Types

You can add a ? modifier to a type name or a variable to specify the nullable version of the type. A nullable value type can have the value Nothing in addition to the values of the non-nullable version of the type.

As a starting point for more information about these features, see Visual Basic Features That Support LINQ and Getting Started with LINQ in Visual Basic.

See Also

Concepts

Visual Basic Features That Support LINQ

Introduction to LINQ in Visual Basic

Basic LINQ Query Operations (C#)

What's New in Visual Studio 2008

What's New in the Visual Basic Compiler

Other Resources

Visual Basic Reference

Language-Integrated Query (LINQ)

Change History

Date

History

Reason

July 2008

Added information and links for If operator, partial methods, and nullable value types.

Information enhancement.