IsStatic
Determines if a type is static by checking if it's abstract, sealed, and has no public constructors.
Source
public static class TypeExtensions
{
public static bool IsStatic(this Type t)
{
var c = t.GetConstructors();
return (t.IsAbstract && t.IsSealed && c.Length == 0);
}
}
Example
Type env = typeof(Environment);
Type str = typeof(String);
string result = String.Format("Env-> {0} Str-> {1}", env.IsStatic(), str.IsStatic());
Console.WriteLine(result);
// Env-> True Str-> False