get type of exception csharp

Code Example - get type of exception csharp

                
                        try
{
    // do something here
}
catch(Exception ex)
{
	// will print System.NullReferenceException for example
    Console.WriteLine(ex.GetType().ToString());
}