Right, I know I am totally going to look an idiot with this one, but my brain is just not kicking in to gear this morning.
I want to have a method where I can sa
The only issue with the solution is that it is possible to create a subclass of Exception which does not implement a constructor with a single string parameter, so the MethodMissingException might be thrown.
static void TestException(string message) where E : Exception, new()
{
try
{
return Activator.CreateInstance(typeof(E), message) as E;
}
catch(MissingMethodException ex)
{
return new E();
}
}