New Features in C# 2.0
by Bradley Jones
From the July 26th CodeGuru newsletter.
The C# language is standardized through ECMA International. This allows for a standardization of the language without the fear of one company controlling it. Said another way, C# is a non-proprietary language that no single company can control.
The ECMA committee has recently accepted two new specifications. These are the Standard ECMA-334: C# Language Specification and the Standard ECMA-335: Common Language Infrastructure (CLI) Specification. I took a quick look at these.
The acceptance of ECMA-334 is the approval of the third edition of the C# language. This standard specifies the syntax and constraints used to create a standard C# program. Additionally, it defines the semantic rules for interpreting C# programs and the restrictions and limits that must be met to be considered a conforming version of C#.
More specifically, what does this mean to a C# developer? It means that a number of new features can be used with confidence because future C# compilers will be supporting them. These features include:
- Pragma directives
- Anonymous methods
- Static classes
- Partial declarations (article)
- Property get and set accessors
- Generic types and methods (article)
- Nullable types
With the changes that have been made to the C# language, it is also not surprising that changes also needed to be made within the standardized CLI specification. Changes in the CLI based on ECMA-335 are:
- Support for generic types and methods.
- Additional prefixes of constrained., no., and readonly.
- Additional instructions of Idelem, stelem, and unbox.any.
- Added a number of members and types to the Type library.
- Made changes to the specification including the addition of a "Debug Interchange Format" section.
In the CLI, there are numerous types and members that were added to the type library. These include a number of generics in the System namespace ranging from Action<T> to TypedReference. The System.Collections.Generics namespace was also added along with numerous types within it. The System.Reflection namespace was updated to allow for support of generics reflection as well to include new enumeration values to support non-standard encoding of String formatting attributes. The System.Runtime.CompilerServices namespace was updated to include types CompilationRelaxations and CompilationRelaxationsAttribute. Finally, the System.Threading.Parallel namespace now contains a number of new types for supporting multithreaded CPUs.
As you can see, C# and the .NET Framework are evolving. These new additions help to boost C# into being an even more powerful, non-proprietary, standardized language. Although Microsoft may be initiating the changes, it is good to know that a standards board is controlling the language. In my opinion, this gives C# developers some added protection as the C# language continues to evolve.
# # #