C# determining generic type
Posted
by Chris Klepeis
on Stack Overflow
See other posts from Stack Overflow
or by Chris Klepeis
Published on 2010-05-27T17:34:55Z
Indexed on
2010/05/27
17:41 UTC
Read the original article
Hit count: 157
I have several templated objects that all implement the same interface:
I.E.
MyObject<datatype1> obj1;
MyObject<datatype2> obj2;
MyObject<datatype3> obj3;
I want to store these objects in a List... I think I would do that like this:
private List<MyObject<object>> _myList;
I then want to create a function that takes 1 parameter, being a datatype, to see if an object using that datatype exists in my list.... sorta clueless how to go about this. In Pseudo code it would be:
public bool Exist(DataType T)
{
return (does _myList contain a MyObject<T>?);
}
© Stack Overflow or respective owner