c# - Is it possible to have a generic delegate? -


i have base generic usercontrol defined as:

public partial class baseusercontrol<t> : usercontrol t : class {     public event itemsselectedeventhandler itemsselected; } 

and delegate:

public class itemsselectedeventargs<t> : eventargs {     public ienumerable<t> items { get; private set; }      internal itemsselectedeventargs(ienumerable<t> items)     {         this.items = items;     } } public delegate void itemsselectedeventhandler(object sender, itemsselectedeventargs<t> e); 

a method of usercontrol load multiple records @ once , return them ienumerable<t>. inheriting controls of concrete type, , in turn raise event subscriber (ie. form).

however, above doesn't compile , following error:

the type or namespace name 't' not found (are missing using directive or assembly reference?)

is possible achieve want need in other way?

of course can. error in last line - haven't declared "t" generic. instead of:

public delegate void itemsselectedeventhandler(object sender, itemsselectedeventargs<t> e); 

it should be:

public delegate void itemsselectedeventhandler<t>(object sender, itemsselectedeventargs<t> e); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -