You can do:
public bool ContainsType(this IEnumerable collection, Type type) { return collection.Any(i => i.GetType() == type); }
And then call it like this:
bool hasType = coll.ContainsType(typeof(T1));
If you want to see if the collection contains a type that can be converted to the specified type, you can do:
bool hasType = coll.OfType<T1>().Any();
This is different, though, since it will return true if the command also contains any subclasses of T1.
Reed copsey
source share