Click here to Skip to main content
15,915,042 members
Home / Discussions / C#
   

C#

 
GeneralRe: go to next Pin
abu rakan12-Jan-09 11:50
abu rakan12-Jan-09 11:50 
GeneralRe: go to next Pin
Wendelius12-Jan-09 12:05
mentorWendelius12-Jan-09 12:05 
QuestionC# application to parse a sharepoint list Pin
pippyn12-Jan-09 8:14
pippyn12-Jan-09 8:14 
AnswerRe: C# application to parse a sharepoint list Pin
Not Active12-Jan-09 8:37
mentorNot Active12-Jan-09 8:37 
QuestionInsert a Page Break In word Using C# Pin
vikram_asv12-Jan-09 7:57
vikram_asv12-Jan-09 7:57 
AnswerRe: Insert a Page Break In word Using C# Pin
Jimmanuel12-Jan-09 9:38
Jimmanuel12-Jan-09 9:38 
QuestionGeneric event, or raise event based on generic type. Pin
DaveyM6912-Jan-09 7:23
professionalDaveyM6912-Jan-09 7:23 
AnswerRe: Generic event, or raise event based on generic type. Pin
Gideon Engelberth12-Jan-09 8:46
Gideon Engelberth12-Jan-09 8:46 
The short answer is you are not allowed to do that.

The long answer would involve looking into how delegates work under the covers. In general, an event declaration get translated into a delegate class member, an add handler function, and a remove handler function (Reflector should be useful in seeing the gory details). This means that for each possible generic argument that you will use to qualify the event, there would need to be a corresponding delegate member and add/remove functions. This is something the compiler will never be able to do. [Except possibly in a few rare circumstances when the only possible way to call and handle the event is entirely contained within the same library (Yes, there are a lot of qualifiers in that statement. That's the point)]

I would have expected the compiler to let you declare an event with a generic signature in a generic class, but that does not seem to work either. I tried something like this:
public class test<T>
{
  public event EventHandler<TEventArgs<T>> Notification;
}


and got a compile error. I expected this to work because I thought the compiler would only have to output one delegate that would then be qualified fully when the generic class is given a type argument, but the compiler disagrees.
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6912-Jan-09 8:52
professionalDaveyM6912-Jan-09 8:52 
GeneralRe: Generic event, or raise event based on generic type. Pin
Gideon Engelberth12-Jan-09 11:58
Gideon Engelberth12-Jan-09 11:58 
AnswerRe: Generic event, or raise event based on generic type. Pin
S. Senthil Kumar12-Jan-09 9:55
S. Senthil Kumar12-Jan-09 9:55 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6912-Jan-09 10:07
professionalDaveyM6912-Jan-09 10:07 
GeneralRe: Generic event, or raise event based on generic type. Pin
Mark Churchill12-Jan-09 16:45
Mark Churchill12-Jan-09 16:45 
GeneralRe: Generic event, or raise event based on generic type. Pin
S. Senthil Kumar12-Jan-09 18:40
S. Senthil Kumar12-Jan-09 18:40 
GeneralRe: Generic event, or raise event based on generic type. Pin
Mark Churchill12-Jan-09 19:01
Mark Churchill12-Jan-09 19:01 
QuestionRe: Generic event, or raise event based on generic type. Pin
Wendelius12-Jan-09 11:16
mentorWendelius12-Jan-09 11:16 
AnswerRe: Generic event, or raise event based on generic type. [modified] Pin
DaveyM6912-Jan-09 22:58
professionalDaveyM6912-Jan-09 22:58 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius13-Jan-09 9:47
mentorWendelius13-Jan-09 9:47 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6914-Jan-09 0:23
professionalDaveyM6914-Jan-09 0:23 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius14-Jan-09 2:30
mentorWendelius14-Jan-09 2:30 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6914-Jan-09 3:25
professionalDaveyM6914-Jan-09 3:25 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius14-Jan-09 3:42
mentorWendelius14-Jan-09 3:42 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6914-Jan-09 11:41
professionalDaveyM6914-Jan-09 11:41 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius14-Jan-09 11:59
mentorWendelius14-Jan-09 11:59 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6915-Jan-09 3:13
professionalDaveyM6915-Jan-09 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.