ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ToException

Turns any object to Exception. Very useful!

Source

public static Exception ToException(this object o)
{
return new Exception(o.ToString());
}

Example

Object o = new Object();
throw o.ToException();

Author: Francisca Garse

Submitted on: 16 nov. 2012

Language: C#

Type: System.Exception

Views: 9901