Udostępnij za pośrednictwem


What's New in Visual Basic 2010

This page lists the new and enhanced features available in Visual Basic 2010. Click the links in the following sections to read more about a feature.

Topic Contents

New in the SP1 Version of Visual Basic 2010

  • Compiler Runtime Switch

New in Visual Basic 2010 Original Release Version

  • Auto-Implemented Properties

  • Collection Initializers

  • Implicit Line Continuation

  • Multiline Lambda Expressions and Subroutines

  • New Command-Line Option for Specifying a Language Version

  • Type Equivalence Support

  • Dynamic Support

  • Covariance and Contravariance

  • Navigate To

  • Highlighting References

  • Generate From Usage

  • IntelliSense Suggestion Mode

Sample Applications

New in the SP1 Version of Visual Basic 2010

The following section describes a new feature of the SP1 version of Visual Basic 2010.

Compiler Runtime Switch

The /vbruntime compiler option has a new /vbruntime* switch that embeds core functionality from the Visual Basic Runtime Library into an assembly. You can use this switch to enable your Visual Basic application to run on platforms that do not contain the Visual Basic Runtime Library.

New in Visual Basic 2010 Original Release Version

The following sections describe the new and enhanced features of the original release version of Visual Basic 2010.

Auto-Implemented Properties

Auto-implemented properties provide a shortened syntax that enables you to quickly specify a property of a class without having to write code to Get and Set the property. For more information, see Auto-Implemented Properties (Visual Basic).

Collection Initializers

Collection initializers provide a shortened syntax that enables you to create a collection and populate it with an initial set of values. Collection initializers are useful when you are creating a collection from a set of known values, for example, a list of menu options or categories. For more information, see Collection Initializers Overview (Visual Basic).

Implicit Line Continuation

In many cases, implicit line continuation enables you to continue a statement on the next consecutive line without using the underscore character (_). For a list of all the cases in which you can omit an underscore character, see Statements in Visual Basic.

Multiline Lambda Expressions and Subroutines

Lambda expression support has been expanded to support subroutines in addition to multiline lambda functions and subroutines. For more information, see Lambda Expressions (Visual Basic).

New Command-Line Option for Specifying a Language Version

The /langversion command-line option causes the compiler to accept only syntax that is valid in the specified version of Visual Basic.

Type Equivalence Support

You can now deploy an application that has embedded type information instead of type information that is imported from a Primary Interop Assembly (PIA). With embedded type information, your application can use types in a runtime without requiring a reference to the runtime assembly. If various versions of the runtime assembly are published, the application that contains the embedded type information can work with the various versions without having to be recompiled. For more information, see /link (Visual Basic). For examples, see Walkthrough: Embedding Type Information from Microsoft Office Assemblies (C# and Visual Basic) and Walkthrough: Embedding Types from Managed Assemblies (C# and Visual Basic).

Dynamic Support

Visual Basic binds to objects from dynamic languages such as IronPython and IronRuby. For more information, see Working with Dynamic Objects (Visual Basic) and Walkthrough: Creating and Using Dynamic Objects (C# and Visual Basic).

Covariance and Contravariance

Covariance enables you to use a more derived type than that specified by the generic parameter, whereas contravariance enables you to use a less derived type. This allows for implicit conversion of classes that implement variant interfaces and provides more flexibility for matching method signatures with variant delegate types. You can create variant interfaces and delegates by using the new In and Out language keywords. The .NET Framework also introduces variance support for several existing generic interfaces and delegates, including the IEnumerable<T> interface and the Func<TResult> and Action<T> delegates. For more information, see Covariance and Contravariance (C# and Visual Basic).

You can use the Navigate To feature to search for a symbol or file in source code. You can search for keywords that are contained in a symbol by using Camel casing and underscore characters to divide the symbol into keywords.

For more information, see How to: Search for Objects, Definitions, and References (Symbols).

Highlighting References

When you click a symbol in source code, all instances of that symbol are highlighted in the document.

For many control structures, when you click a keyword, all of the keywords in the structure are highlighted. For instance, when you click If in an If...Then...Else construction, all instances of If, Then, ElseIf, Else, and End If in the construction are highlighted.

To move to the next or previous highlighted symbol, you can use CTRL+SHIFT+DOWN ARROW or CTRL+SHIFT+UP ARROW. For more information, see How to: Use Reference Highlighting.

Generate From Usage

The Generate From Usage feature enables you to use classes and members before you define them. You can generate a stub for any class, constructor, method, property, field, or enum that you want to use but have not yet defined. You can generate new types and members without leaving your current location in code. This minimizes interruption to your workflow.

Generate From Usage supports programming styles such as test-first development. For more information, see Generate From Usage.

IntelliSense Suggestion Mode

IntelliSense now provides two alternatives for IntelliSense statement completion: completion mode and suggestion mode. Suggestion mode is used when classes and members are used before they are defined. For more information, see List Members.

Sample Applications

Visual Basic includes new sample applications that demonstrate the following features: auto-implemented properties, implicit line continuation, collection initializers, covariance and contravariance, and multiline lambda expressions and subroutines. For information about Visual Basic language samples and how to access them, see Visual Basic Language Samples.

See Also

Reference

What's New in the Visual Studio Debugger

Concepts

What's New in Visual Studio 2010

What's New in Deployment

What's New in the .NET Framework 4

What's New in ASP.NET 4 and Visual Web Developer