How to detect if collection contain instance of specific type?

Posted by KentZhou on Stack Overflow See other posts from Stack Overflow or by KentZhou
Published on 2010-03-22T19:48:19Z Indexed on 2010/03/22 19:51 UTC
Read the original article Hit count: 213

Filed under:
|

Suppose I create collection like

Collection<IMyType> coll;

Then I have many implelentations of IMyTypem like, T1, T2, T3...

Then I want know if the collection coll contains a instance of type T1. So I want to write a method like

public bool ContainType( <T>){...}

here the param should be class type, not class instance. How to write code for this kind of issue?

© Stack Overflow or respective owner

Related posts about c#

Related posts about collections