With the release of Visual Studio 2005, the C # language has been updated to version 2.0. It supports the following new features:
1. Generic
Some generic types are added to this language, so that programmers can achieve high degree of code reuse and achieve higher collection class performance. The generic type only varies with the arity. You can also force a parameter to a specific type.
2 iterator
The iterator makes it easier to define how a foreach loop cyclically accesses the content of a set.
3. Division
The Division type definition allows you to split a single type (such as a class) into multiple files. The Visual Studio designer uses this function to separate the code it generates from the user code.
4. null type
An empty type allows variables to contain undefined values. You can use an empty type when using a database and other data structures that may contain elements that do not contain specific values.
5 anonymous method
Currently, the code block can be passed as a parameter. Code blocks can be used to replace any part of the delegate: no new methods need to be defined.
6. namespace alias qualifier
The namespace alias qualifier (: :) provides more control over access to namespace members. Global: the alias allows access to the root namespace that may be hidden by the entity in the code.
7 static class
To declare classes that contain static methods that cannot be instantiated, static classes are safe and convenient. C #1.2 requires class constructors to be defined as private to prevent classes from being instantiated.
8. External Assembly alias
This extension usage of the extern keyword references different versions of the same component contained in the same assembly.
9 attribute accessors accessibility
You can now define different levels of accessibility for the get and set accessors of the attribute.
10. Co-Variation and inverter in Delegation
The Methods passed to the delegate can be more flexible in the return type and parameters.
11 how to: declare, instantiate, and use a delegate
Method group conversion provides a simpler syntax for declarative delegation.
12 fixed buffer size
In Insecure code blocks, you can now declare a fixed size structure that contains an embedded array.
13 youyuan assembly
An assembly can provide non-public access to other assemblies.
14 inline Warning Control
# The pragma warning command can be used to disable and enable certain compiler warnings.
15 volatile
Now you can apply the volatile keyword to IntPtr and UIntPtr.