Welcome to MSDN Blogs Sign in | Join | Help

Kavitak's WebLog

My space on the web...

Syndication

News

Kavita Kamani works at Microsoft. Everything here, though, is her personal opinion and is not read or approved by Microsoft before it is posted. No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here.
Cool article on the new C# features

If you want a two page summary on what's new in the C# language in Whidbey, this article is for you:

http://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx

The three main ones discussed, among all the others:

- support for generics. Previously, if a collection contained value types, iterating over the elements would cause boxing and unboxing of those items. Now there are IEnumerable/IEnumerator interfaces that are type-safe and use generics to avoid this penalty.

- partial types. For the traditional C++ programmer, this is not new. You can now split the definition and implementation of a class or a struct across multiple files.

- and the coolest -- Anonymous delegates -- you dont need to create a class or a method just for the sake of using a delegate. You can now have anonymous methods and inline the code!

 

C# supports delegates for invoking one or multiple methods. Delegates provide operators and methods for adding and removing target methods, and are used extensively throughout the .NET Framework for events, callbacks, asynchronous calls, and multithreading. However, you are sometimes forced to create a class or a method just for the sake of using a delegate. In such cases, there is no need for multiple targets, and the code involved is often relatively short and simple. Anonymous methods is a new feature in C# 2.0 that lets you define an anonymous (that is, nameless) method called by a delegate.

 

Published Friday, April 16, 2004 10:03 AM by kavitak

Filed under:

Comments

No Comments

Anonymous comments are disabled
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement  
Page view tracker