……………………………………………….Expertise in .NET Technologies

What’s New in the C# 2.0 Languages and Compiler?

Posted by Ravi Varma Thumati on October 2, 2009

With the release of Visual Studio 2005, the C# language has been updated to version 2.0, which supports the following new features:


Generic types are added to the language to enable programmers to achieve a high level of code reuse and enhanced performance for collection classes. Generic types can differ only by parity. Parameters can also be forced to be specific types.


Iterators make it easier to dictate how a foreach loop will iterate over a collection’s contents.

Partial Classes

Partial type definitions allow a single type, such as a class, to be split into multiple files. The Visual Studio designer uses this feature to separate its generated code from user code.

Nullable Types

Nullable types allow a variable to contain a value that is undefined. Nullable types are useful when working with databases and other data structures that may contain elements that contain no specific values.

Anonymous Methods

It is now possible to pass a block of code as a parameter. Anywhere a delegate is expected, a code block can be used instead: there is no need to define a new method.

Namespace alias qualifier

The namespace alias qualifier (::) provides more control over accessing namespace members. The global:: alias allows access the root namespace that may be hidden by an entity in your code.

Static Classes

Static classes are a safe and convenient way of declaring a class containing static methods that cannot be instantiated. In C# version 1.2 you would have defined the class constructor as private to prevent the class being instantiated.

External Assembly Alias

Reference different versions of the same component contained in the same assembly with this expanded use of the extern keyword

Property Accessor Accessibility

It is now possible to define different levels of accessibility for the get and set Accessors on properties.

Covariance and Contravariance in Delegates

The method passed to a delegate may now have greater flexibility in its return type and parameters.

How to: Declare, Instantiate, and Use a Delegate

Method group conversion provides a simplified syntax for declaring delegates.

Fixed Size Buffers

In an unsafe code block, it is now possible to declare fixed-size structures with embedded arrays.

Friend Assemblies

Assemblies can provide access to non-public types to other assemblies.

Inline warning control

The #pragma warning directive may be used to disable and enable certain compiler warnings.


The volatile keyword can now be applied to IntPtr and UIntPtr.

The C# compiler introduces the following additions and changes for this release:

/errorreport option

Can be used to report internal compiler errors to Microsoft over the Internet.

/incremental option

Has been removed.

/keycontainer and /keyfile options

Support specifying cryptographic keys.

/langversion option

Can be used to specify compatibility with a specific version of the language.

/linkresource option

Contains additional options.

/moduleassemblyname option

Allows you to build a .netmodule file and access non-public types in an existing assembly.

/pdb option

Specifies the name and location of the .pdb file.

/platform option

Enables you to target Itanium Family (IPF) and x64 architectures.

#pragma warning

Used to disable and enable individual warnings in code.


One Response to “What’s New in the C# 2.0 Languages and Compiler?”

  1. Nice read, I just passed this onto a colleague who was doing some research on that. And he actually bought me lunch as I found it for him smile Thus let me rephrase that: Thanks for lunch!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: