SystemType
Description
Static class providing pre-cached Type instances for common .NET types. Avoids repeated typeof() calls throughout the framework and in consumer code.
Features
Covers all common types:
- Primitives:
string,int,long,short,bool,char,byte,double,decimal,float,uint,ulong,ushort - Dates:
DateTime,DateTimeOffset,TimeSpan— including nullable variants - Collections:
IList,ICollection,IDictionary,List<>,Dictionary<,>— generic and non-generic - Other:
Guid,Uri,object,ExpandoObject,Delegate,Tuple,BigInteger,Half - Attributes:
EnumValueAttribute,EnumTextAttribute - Arrays:
byte[],int[]
Behavior
All fields are static and initialized once at class load — zero overhead after first access.
Caveats
- Fields are
public staticnotreadonly— technically mutable, but should never be reassigned
Tip
Use SystemType.IntType instead of typeof(int) in hot paths — the cached instance avoids repeated type resolution overhead. Particularly useful in reflection-heavy code called frequently.
Usage
if(type == SystemType.IntType)
{
...
}