In C#, how can I find out if a Type
can be instantiated? I am trying to avoid an Activator.CreateInstance exception.
My current method is type.IsClass && !type.IsInterface
, but I am worried this could fail on abstract classes, etc. I also considered checking type.TypeInitializer == null
, but I am not sure if that is foolproof either.
What is the simplest/most efficient way possible to find out if a Type
is instantiable?