Is this the best method for getting the name of a specific Exception in C#:
ex.GetType().ToString()
It is in a generic exception handler:
catch (Exception ex)
Is this the best method for getting the name of a specific Exception in C#:
ex.GetType().ToString()
It is in a generic exception handler:
catch (Exception ex)
ex.GetType().Name
or ex.GetType().FullName
for the fully qualified name.
Try ex.GetType().Name
try
{
object test = null;
test.ToString();
}
catch (Exception ex)
{
Console.WriteLine(ex.GetType().Name);
}
Gives this..
NullReferenceException