What's New in Visual C#

What's New in Visual C# 2008 Service Pack 1

C# Language



Various Compiler Improvements

Many improvements have been made to the C# compiler to remove inconsistencies with the language specification. Some of these improvements are breaking changes, but others are just software updates or enhancements. For more information about the breaking changes, see Visual C# 2008 Breaking Changes. For more information about the other bugs fixed in Service Pack 1, see List of changes and fixed issues for Visual Studio 2008 Service Pack 1 Beta for Visual C#.

Visual C# IDE



Live Semantic Errors

Visual C# 2008 Service Pack 1 introduces Live Semantic Errors, a new feature that provides a more complete set of error information about your code. This feature detects expression-level errors that were previously reported only after a build. It highlights the errors with red wavy underlines as you write code. For more information about wavy underlines, see Editing Code (Visual C#).

LINQ Query Debugging

Debugging of LINQ queries is greatly enhanced in Service Pack 1.

  • Range variables can now be viewed in the Watch window and in DataTips when you step through individual lines in a query expression.

  • The debugger no longer hides anonymous type names, and it allows them to appear in casts and instantiations. This enables temporary instances of anonymous types to be created during a debugging session. Casts to and from anonymous types are evaluated correctly.

  • The strings generated for Add to Watch have been improved and generate expressions that can be evaluated more often than in the original release version of Visual Studio 2008.

For more information, see Sree's ventures in code space on the Microsoft Web site.

Task List Comments Are Displayed for All Files in Solution

In previous releases of Visual Studio, the task list was populated only with task comments in open files. In Visual Studio 2008 Service Pack 1, the C# integrated development environment (IDE) displays the task comments in all open and closed files in the solution. For more information, see How to: Create Task List Comments.

Rename Refactoring in Windows Presentation Foundation Projects

Visual Studio 2008 Service Pack 1 enables you to use the rename refactoring feature to rename references that are defined in XAML. For more information about rename refactoring, see Rename.




Improvements to the System.Linq.Enumerable.Cast<T> Method

Visual C# 2008 Service Pack 1 improves the performance of the Enumerable.Cast<T> method by disabling the primitive value conversions and the explicitly defined user conversions. An example of a primitive value conversion is a conversion from the int data type to the long data type.

Improvements in the Performance of System.Linq.Enumerable.Where<TSource> and System.Linq.Enumerable.Select<TSource, TResult> Methods

Visual C# 2008 Service Pack 1 improves the performance of the Where standard query operator and of the Select standard query operator.

What's New in the Original Release Version of Visual C# 2008

C# 3.0 Language

The C# 3.0 language and compiler introduce several new language features. These new language constructs are useful individually in various contexts, and collectively for doing Language-Integrated Query (LINQ). For more information about LINQ, see The LINQ Project.

The following table lists the new C# 3.0 language features:



Implicitly Typed Local Variables and Arrays

When used with local variables, the var keyword instructs the compiler to infer the type of the variable or the array elements from the expression on the right side of the initialization statement.

Object Initializers

Enables object initialization without explicit calls to a constructor.

Collection Initializers

Enables initialization of collections with an initialization list rather than specific calls to Add or another method.

Extension Methods

Extend existing classes by using static methods that can be invoked by using instance method syntax.

Anonymous Types

Enables on-the-fly creation of unnamed structured types that can be added to collections and accessed by using var.

Lambda Expressions

Enables inline expressions with input parameters that can be bound to delegates or expression trees. See also Anonymous Functions (C# Programming Guide).

Query Keywords

Keywords that specify clauses in a query expression:

  • from clause(s)

  • where clause (optional)

  • ordering clauses (optional)

  • join clause (optional)

  • select or group clause

  • into clause (optional)

Auto-Implemented Properties

Enables declaration of properties by using simplified syntax.

Partial Method Definitions

Partial types may now contain partial methods.

C# 3.0 Compiler

  • /win32Manifest and /noWin32Manifest compiler switches.
    These new compiler switches are used to specify requested execution levels for programs running on Windows Vista.

Visual C# IDE




Visual Studio 2008 enables you to specify a version of the .NET Framework for your project, .NET Framework 2.0, 3.0, or 3.5. The .NET Framework target of an application is the version of the .NET Framework that is required on a computer to enable the application to run on that computer. For more information, see Targeting a Specific .NET Framework.

New Project Types and Templates

Several new project templates are provided for Windows Presentation Foundation, Windows Communication Foundation, and Web projects. For more information, see Project Templates in Visual C# Editions and Default Project Templates in Visual Studio.

IntelliSense support for C# 3.0

The Visual C# code editor provides statement completion and Quick Info to support the following new language constructs in C# 3.0:

  • Implicitly Typed Local Variables

  • Query Expressions

  • Extension Methods

  • Object/Collection Initializers

  • Anonymous Types

  • Lambda Expressions

  • Partial Methods

For more information, see Visual C# IntelliSense.

Refactoring Support for C# 3.0

The refactoring features, Rename, Signature Change, Extract Method, and Promote Local have been updated to support the following new language constructs:

  • Query Expressions

  • Extension Methods

  • Lambda Expressions

In addition, refactoring provides new options and warnings to help prevent unintended consequences from a refactoring action. For more information, see Refactoring.

Code Formatting

The code editor supports formatting options for several new C# 3.0 language constructs including query expressions. For more information, see Formatting, C#, Text Editor, Options Dialog Box.

Organizing Using Statements

The Visual C# code editor provides an easy way to sort using and extern declarations and remove those that are not being used.

See Also

Other Resources

Language-Integrated Query (LINQ)

Is C# becoming a functional language?

The Evolution Of LINQ And Its Impact On The Design Of C#

New Library Classes in the .NET Framework 3.5

Change History




July 2008

Added section about Visual C# 2008 Service Pack 1.

SP1 feature change.