The C# 2.0 Language - What’s New (Part I)

Posted by: Suprotim Agarwal , on 3/11/2007, in Category C#
Views: 57343
Abstract: C# was created by Microsoft as a major part of its .NET initiative. C# is a modern, powerful, component-orientated, flexible, safe, internet friendly and an easy to use language that takes advantage of virtually any feature in this platform. Well people familiar with C# 1.1 know that. This article is a two part series. Let us explore what’s new in C# 2.0
Introducing C# 2.0
With the release of Visual Studio 2005 (formerly codenamed Whidbey), C# is back with some new innovations. The C# language has been updated to version 2.0 and comes with several language extensions which we will explore in this 2 part series article. Besides Generic types, the C# language introduces some other interesting features such as Iterators, Partial Classes and Anonymous methods, which are briefly mentioned below.
Although new to the .NET platform, this concept has been around for years. Generics is a term used to describe generic types. It greatly enhances application performance and type safety and allows you to write highly general, flexible and safe code. It permits classes, interfaces, structs, delegates and methods to be parameterized by the types of data they store and manipulate.
Iterators specify how a for-each loop will iterate over a collection and return its internal items. They allow you to create enumerable classes with minimum coding.
Partial Classes
Partial Classes allows you to split a single type, like your class, across more than one file (.cs). They are useful if you have extremely large, unwieldy types.
Nullable Types
Nullable types allow a variable to contain a value that is undefined. This is useful when working with databases where the value returned might be null
Anonymous Methods
Anonymous Methods Are Inline Delegates. It enables you to pass a block of code as a parameter. Anonymous methods enables you to directly associate a block of code statements to a given event. You use them anywhere a delegate is used . So there is no need to define a new method.
Namespace alias qualifier
C# 2.0 adds the namespace alias qualifier, the :: operator, to provide more control over accessing namespace members.
Static Classes
With C# 2.0, now you also can declare classes as static. This signals the compiler that this class should not be instantiated and can only contains static members.
Property Accessor Accessibility
C# 2.0 allows a fine control over the accessibility of accessors and indexers within a property.
Covariance and Contravariance in Delegates
The method passed to a delegate may now have greater flexibility in its return type and parameters.
In this article, we explored the various new features introduced in C# 2.0. In Part two, we will explore these new features in detail.

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigious Microsoft MVP award for Sixteen consecutive years. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that offers Digital Marketing and Branding services to businesses, both in a start-up and enterprise environment.

Get in touch with him on Twitter @suprotimagarwal or at LinkedIn

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by kamal on Saturday, September 8, 2007 2:01 AM
By the above information i got some idea about c# 2.o.
I want differences between c#.Net,vb.NET&asp.NET
please send information about these
Comment posted by suprotim on Thursday, September 20, 2007 7:38 AM
Check this link for differences between and C#
Comment posted by moheed_dotnet on Monday, April 7, 2008 11:33 AM
need to expand the topics and give some good examples also.
Comment posted by Muthu on Saturday, June 21, 2008 10:44 AM
Comment posted by g on Wednesday, July 9, 2008 3:03 AM
Comment posted by prashant on Tuesday, October 7, 2008 11:37 AM
What are the facts and figures about job opportunities in .Net Vs Java?
Comment posted by Siddartha12002 on Friday, December 5, 2008 4:00 AM