I want to check if an object is not of a particular type. I know how to check if something is of a particular type:
if (t is TypeA) { ... }
Extensions methods to the rescue!!
public static class ObjectExtensions { public static bool Isnt(this object source, Type targetType) { return source.GetType() != targetType; } }
Usage
if (t.Isnt(typeof(TypeA))) { ... }