Friday, October 24, 2003
C# Language Specification 2.0
The C# language will get a pile of new features in its second release. There's a C# Version 2.0 Specification document on Microsoft's web site that goes into detail on new features. Major highlights include:
It will be interesting to see if C# and Java continue to "one up" one another over the next few years or plateau at a certain level of complexity. Unconstrained language evolution is hard since design choices made earlier constraint what you can add. (Via Lambda the Ultimate)• Generics permit classes, structs, interfaces, delegates, and methods to be parameterized by the types of data they store and manipulate. Generics are useful because they provide stronger compile-time type checking, require fewer explicit conversions between data types, and reduce the need for boxing operations and run-time type checks.
• Anonymous methods allow code blocks to be written "in-line" where delegate values are expected. Anonymous methods are similar to lambda functions in the Lisp programming language. C# 2.0 supports the creation of "closures" where anonymous methods access surrounding local variables and parameters.
• Iterators are methods that incrementally compute and yield a sequence of values. Iterators make it easy for a type to specify how the foreach statement will iterate over its elements.
• Partial types allow classes, structs, and interfaces to be broken into multiple pieces stored in different source files for easier development and maintenance. Additionally, partial types allow separation of machine-generated and user-written parts of types so that it is easier to augment code generated by a tool.
RSS 0.92 Feed