Monday, May 25, 2009

What's New in Visual C# 2010

C# 4.0 Language and Compiler

Dynamic Support

Visual C# 2010 provides support for late binding to dynamic types by introducing a new type, dynamic. This addition enables many new scenarios, including simplified access to COM APIs such as the Office Automation APIs, to dynamic APIs such as IronPython libraries, and to the HTML Document Object Model (DOM). For more information, see Using Type dynamic (C# Programming Guide) and dynamic (C# Reference).

Office Programmability

Access to COM interfaces, including the Office Automation APIs, is greatly enhanced by the addition of named and optional arguments, the dynamic type, and optional ref modifiers. For more information, see Named and Optional Arguments (C# Programming Guide), Using Type dynamic (C# Programming Guide), and How to: Access Office Interop Objects by Using Visual C# 2010 Features (C# Programming Guide).

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). An application that contains embedded type information 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 (C# Compiler Options). For an example, see Walkthrough: Embedding Types from Managed Assemblies.

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. Variant interfaces and delegates can be created 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<(Of <(T>)>) interface and the Func<(Of <(TResult>)>) and Action<(Of <(T>)>)Covariance and Contravariance (C# and Visual Basic). delegates. For more information, see

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 C#.

The following sections describe enhancements to the Visual Studio integrated development environment (IDE).

Call Hierarchy

Call Hierarchy enables you to navigate through your code by displaying the following:

  • All calls to and from a selected method, property, or constructor

  • All implementations of an interface member

  • All overrides of a virtual or abstract member

This enables you to better understand how code flows and to evaluate the effects of changes to code. For more information, see Call Hierarchy.

Navigate To

You can use the Navigate To feature to search for a symbol or file in source code. For more information, see How to: Search for Objects, Definitions, and References (Symbols).

Highlighting References

This enhancement enables you to highlight all instances of a particular symbol in a document by clicking that symbol. To navigate between references, you can use CTRL+SHIFT+DOWN ARROW or CTRL+SHIFT+UP ARROW. For more information, see How to: Search for Objects, Definitions, and References (Symbols).

Generate From Usage

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

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

IntelliSense Consume-First Mode

IntelliSense now provides two alternatives for IntelliSense statement completion: standard mode and consume-first mode.

Consume-first mode is used when classes and members are used before they are defined. For more information, see List Members.

Visual C# 2010 includes sample applications that demonstrate the use of new C# features to simplify Office programming, provide access to IronPython libraries, create dynamic objects, develop and use covariant and contravariant generic delegates, and more. For information about Visual C# language samples and how to access them, see Visual C# Sample Applications.

Source: http://msdn.microsoft.com/en-us/library/bb383815(VS.100).aspx