.net - Saving an open generic type in an array? -
i facing problem .net generics. thing want saving array of generics types (graphicsitem):
public class graphicsitem<t> { private t _item; public void load(t item) { _item = item; } }
how can save such open generic type in array?
implement non-generic interface , use that:
public class graphicsitem<t> : igraphicsitem { private t _item; public void load(t item) { _item = item; } public void somethingwhichisnotgeneric(int i) { // code goes here... } } public interface igraphicsitem { void somethingwhichisnotgeneric(int i); }
then use interface item in list:
var values = new list<igraphicsitem>();
Comments
Post a Comment