I am writing a simple List
to CSV converter. My converter checks the all the t
\'s in List and grabs all public properties and places them
Namespace-based methods potentially may cause collisions.
There is an another reliable and simple way:
static bool IsSystemType(this Type type) => type.Assembly == typeof(object).Assembly;
Or a little bit more optimal, caching the system assembly:
static readonly Assembly SystemAssembly = typeof(object).Assembly;
static bool IsSystemType(this Type type) => type.Assembly == SystemAssembly;
I prefer
colType.FullName.StartsWith("System")
rather then
colType.Namespace.StartsWith("System")
becose Namespace
may be null.