Geek Noise
Rants, rambles, news and notes by Peter Provost
12

More Tricks w/ C# Generics

Tuesday, 12 August 2003 07:57 by Peter Provost

Christian Nagel shows us another neat trick we can expect out of C# generics:

The declaration

public delegate void EventHander<S, T>(S sender, T args) where T : EventArgs;

also shows a big difference to the template implementation of C++. With C# generics it is possible to define requirements of generic types, such as T needs to be of type of EventArgs (or derived from this class). With C++ templates we just find out that a type doesn't fulfill the requirements when compiling the template using the specific type. Often the compiler error messages with many, many lines are not easy to read.

Very nice. I was an STL junkie I remember all the nasty errors produced by the compiler when you did something wrong. I really like the way that reads too.

Currently rated 1.0 by 9801 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Technology
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed