The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Specifying Requirements w/ C# Generics

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter G Provost

Posts: 849
Nickname: pprovost
Registered: Aug, 2003

Peter G Provost is a Solution Architect for Interlink Group in Denver, CO.
Specifying Requirements w/ C# Generics Posted: Aug 15, 2003 10:03 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter G Provost.
Original Post: Specifying Requirements w/ C# Generics
Feed Title: Peter Provost's Geek Noise
Feed URL: /error.aspx?aspxerrorpath=/Rss.aspx
Feed Description: Technology news, development articles, Microsoft .NET, and other stuff...
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter G Provost
Latest Posts From Peter Provost's Geek Noise

Advertisement

In my post More Tricks w/ C# Generics, I re-posted Don Box's sample that demonstrated the use of the where clause in a generic definition.

Don's code was:

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

Brett Knights asked in the comments of my post what the difference is between Don's code and this:

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

I'm not 100% sure of this, but based on my experience with C++ templates I would suggest that there is a significant difference between Brett's example and Don's. In the former example, you are saying that T should be derived from EventArgs, but within your method T is still "untyped". In other words you can access any public method on T, not just those defined in EventArgs.

In Brett's example you would only be able to call the public methods defined in the EventArg class.

Am I right here? Anyone who actually has Whidbey care to comment?

Read: Specifying Requirements w/ C# Generics

Topic: ASPToday Is Back Previous Topic   Next Topic Topic:

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use