Share via


What's New in Visual C# Express

This topic contains information about new features and enhancements in Visual C# 2008 Express Edition.

Support for Data

There are several new features in Visual C# Express Edition for developing applications that access data.

Language-Integrated Query (LINQ)

Language-Integrated Query (LINQ) is a new set of features that enables applications to query data in Visual C# Express Edition. LINQ introduces standard, easily-learned patterns for querying and transforming data, and it can be extended potentially to support any kind of data source. Visual C# Express Edition includes LINQ provider assemblies that enable you to use LINQ with .NET Framework collections, SQL databases, ADO.NET Datasets, and XML documents.

For more information, see Using LINQ in C# and Language-Integrated Query (LINQ).

Object Relational Designer (O/R Designer)

The Object Relational Designer (O/R Designer) assists developers in creating and editing the LINQ to SQL classes that map between an application and a database. You use the O/R Designer to create classes that map to database objects that you can access and query in your code. For more information, see Creating LINQ to SQL Classes with the O/R Designer, O/R Designer Overview, and LINQ to SQL.

Note

The O/R Designer does not support SQL Server Compact 3.5 databases. You can still use SQL Server Compact 3.5 databases, but not with the designer. Instead, you can use SQL Server Express with the designer. For information about how to obtain SQL Server Express Edition, see the Obtaining SQL Server Express Edition section in How to: Install Sample Databases.

Microsoft SQL Server Compact 3.5

Microsoft SQL Server Compact 3.5 is a compact database that enables you to use local data in applications that you create by using Visual C# Express Edition. You can easily connect to data in a SQL Server Compact 3.5 database, and bind the data to controls on a Windows Forms application or Windows Presentation Foundation application. For more information, see Connecting to Data (Visual C#), Using SQL Server Compact 3.5 (Visual Studio), and How to: Add a SQL Server Compact 3.5 Database to a Project.

Language Features

There are several new language features in the C# 3.0 language and compiler. Many of these features are made available to support Language-Integrated Query (LINQ). For more information about LINQ, see The LINQ Project.

Implicitly Typed Local Variables

Instead of explicitly specifying the type of a local variable, the var keyword instructs the compiler to infer the type of a variable based on the value assigned at initialization. In the following code, the variable is declared explicitly:

int totalCards = 52;

By using local type inference, you can declare the variable without specifying its type, as the following code demonstrates:

var totalCards = 52;

Even though you don't specify the type, it is determined when you write your code, at design time (early binding), instead of at run time (late binding). This is because it is inferred from the value that you assign. In both cases, totalCards is strongly typed as an Integer. For more information, see Implicitly Typed Local Variables (C# Programming Guide).

Object Initializers

Object initializers enable initialization of an object without an explicit call to a constructor. For example, you can create an instance of an Address object and specify its properties all in the same declaration, as the following code demonstrates:

Address homeAddress = new Address {Street = "123 Main",
    City ="Kirkland", State="WA", PostalCode ="18033"};

For more information, see Object and Collection Initializers (C# Programming Guide).

Collection Initializers

Collection initializers enable initialization of a collection by using a list instead of by making multiple explicit calls to the Add method of the collection. For example, you can add multiple items to a collection in one line, as the following code demonstrates:

List<int> years = new List<int> { 2005, 2006, 2007 };

For more information, see Object and Collection Initializers (C# Programming Guide).

Extension Methods

Extension methods enable you to extend existing classes. For example, you could add custom functionality to an existing data type, such as String. For more information, see Extension Methods (C# Programming Guide).

Anonymous Types

The anonymous types feature enables you to create an object without explicitly defining its type. Instead, the compiler defines the type of the data based on the properties you specify when the object is created. Because these are new types defined by the compiler, they do not have names and therefore they are known as anonymous types.

var homeAddress = new {Street = "123 Main", City = "Kirkland",
    State = "WA", PostalCode = "18033"};

For more information, see Anonymous Types (C# Programming Guide).

Lambda Expressions

Lambda expressions are inline expressions with input parameters that can be used where a delegate type is expected. Lambdas are used extensively in LINQ queries that call certain Standard Query Operator methods directly. For more information, see Lambda Expressions (C# Programming Guide).

Query Keywords

There are several keywords, such as select, from, where, and into, that can be used in query expressions. These query keywords enable you to specify a database, indicate a column in the database, and filter data and group results. For more information, see Query Keywords (C# Reference).

Auto-Implemented Properties

Auto-implemented properties provide a simplified syntax for the declaration of properties. Auto-implemented properties must declare both a get and a set accessor. For more information, see Auto-Implemented Properties (C# Programming Guide).

Partial Method Definitions

Partial classes or structs can now contain partial methods. A partial method declaration must consist of the definition of the method and the implementation. For more information, seePartial Classes and Methods (C# Programming Guide).

Project Designer Support for Windows Presentation Foundation (WPF) Applications

Windows Presentation Foundation (WPF) applications have been added to Visual C# Express Edition. There are two WPF project types:

  • WPF Windows Application (.xaml, .exe)

  • WPF Web Browser Application (.exe, .xbap)

When a WPF project is loaded in the IDE, the user interface of the Project Designer pages provides access to available WPF controls and to properties specific to WPF applications. For more information, see Creating WPF Applications.

WCF Services Consumption

Windows Communication Foundation (WCF) is a new service-oriented programming model that simplifies development of connected applications. Applications created by using Visual C# Express Edition can communicate with (consume) existing Windows Communication Foundation (WCF) services. For more information, see Consuming a WCF Service.

ClickOnce Deployment

ClickOnce deployment has been enhanced to support the deployment of WPF Web Browser Applications. WPF Web Browser Applications are hosted in a Web browser and therefore require special deployment and security settings. When you build and deploy these applications, Visual Studio provides appropriate user interface and default values.

For more information, see What's New in Deployment.

See Also

Other Resources

Getting Started with Visual C# Express

Visual C# Guided Tour