|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
What's New in Visual C#
Updated: July 2008
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.
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.
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:
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.
Enables object initialization without explicit calls to a constructor.
Enables initialization of collections with an initialization list rather than specific calls to Add or another method.
Extend existing classes by using static methods that can be invoked by using instance method syntax.
Enables on-the-fly creation of unnamed structured types that can be added to collections and accessed by using var.
Enables inline expressions with input parameters that can be bound to delegates or expression trees. See also Anonymous Functions (C# Programming Guide).
Keywords that specify clauses in a query expression:
Enables declaration of properties by using simplified syntax.
Partial types may now contain partial methods.
C# 3.0 Compiler
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:
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:
In addition, refactoring provides new options and warnings to help prevent unintended consequences from a refactoring action. For more information, see Refactoring.
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.
The Visual C# code editor provides an easy way to sort using and extern declarations and remove those that are not being used.