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

ToException

Conveniently produces a exception from a given string.

Source

public static class StringExtensions
{
    public static void ToException (this string message)
    {
        throw new Exception(message);
    }
}

Example

"ExceptionText".ToException();

Author: MrMostInteresting

Submitted on: 6 mrt 2015

Language: C#

Type: String

Views: 3009