RSS 2.0 Feed
RSS 2.0


Atom 1.0 Feed
Atom 1.0

  New C# features coming in Whidbey release 


qt8gt0bxhw|20009F4EEE83|RyanMain|subtext_Content|Text|0xfbff7a00000000008e00000001000500

I just listened to the latest .NET Rocks show with Juval Lowy. BTW, if you're a .NET developer, or really any kind of developer, .NET Rocks is a great audio show to listen to. Always great guests and topic discussed. Well worth the time to listen to. Anyway, Juval discusses the new features coming in C# 2.0. Great Stuff (although you'll have to sit through Carl and Mark's rants of why C# developers carry a higher perceived value than VB.NET developers. Not a tough one to figure out IMO - generally speaking - ok, let the flames begin)

First of all, generics. Having a background in C++ and using templates, I am really excited about generics. Essentially, generics are, more or less, a new implementation of C++ templates - but generics in C# do have some huge additional benefits over C++ templates (ie: such as avoiding code bloat).  You can see the official Microsoft documentation on the design and implementation of generics in the CLR here. Basically, generics allows you to define generic types, that are instanciated as a specific underlying type at runtime. So you get the benefits of using late-bound types, but as an early-bound structure - with all the benefits of early-bound types and type safety checking, etc.  Generics allow you to define data structures without committing to actual data types. Here's another good resource on the subject: What are C# generics? on developer.com . Anyway, generics will be great. Gotta take a listen to Juval's interview or read up on it. As always, Juval knows his stuff - as long as you can understand his accent ;-)

Another cool thing is iterators. Iterators simplify the process of building classes that support the C# foreach iteration syntax, absolving programmers of the requirement to implement the IEnumerable interface to enable simple iteration.

Partial types. This feature allows a team of programmers to split large classes containing lots of code into multiple files. Without this capability a team would have to use source code management features such as check-in/check-out and merge changes for multiple programmers to work on a single class; with partial types, each team member can work on a separate part of the class, and the system will handle merging the separate code files back into a single class at compile time.

Anonymous methods. I'm having a hard time getting all that excited about anonymous methods yet, why not just stick with delegates? Maybe I'm just not seeing the entire picture yet until I use them a time or two. I know anonymous methods are available in other languages such as PHP, Lisp, SmallTalk, etc. To me they seem to be just a way to simplify setting up event handling. So instead of setting up an event handler as you would now, like this:

public Form1()
{
    this.Click += new EventHandler(OnClick);
}

private void OnClick(object sender, EventArgs e)
{
    // code to handle click event here
}

So with anonymous methods you can simplify that as this:

public Form1()
{
    this.Click += new EventHandler(sender, e)
    {
         // code to handle click event here
    };// end of anonymous method
}

Well, that is great, but why would you want to do that instead of having a separate event handler and setting it up with a delegate? Seems like it would make the code harder to manage. But that is just me. I suppose you could make the handler be more dynamic that way and change the method body depending on the state of other things in the app.

Anyway, a great time to be a C# developer (assuming your work is not getting offshored from you). You can also check out the Powerpoint presentation from the one and only Mac-Daddy of C#, Anders Hejlsberg from his OOPSLA 2002 presentation introducing C# 2.0 here.

Great stuff.




                   



Leave a comment below.

Comments

  1. Ryan Farley 8/19/2003 12:10 PM
    Gravatar
    The September 2003 issue of MSDN Magazine has a good article on generics in C# 2.0 by Jason Clark.

    Take a look:
    http://msdn.microsoft.com/msdnmag/issues/03/09/NET/

    -Ryan
Comments have been closed on this topic.



 

News


Also see my CRM Developer blog

Connect:   @ryanfarley@mastodon.social

         

Sponsor

Sections