Determine if a type is static

static classes are declared abstract and sealed at the IL level. So, you can check IsAbstract property to handle both abstract classes and static classes in one go (for your use case).

However, abstract classes are not the only types you can’t instantiate directly. You should check for things like interfaces (without the CoClass attribute) and types that don’t have a constructor accessible by the calling code.

Leave a Comment