LANGUAGE

throw statement

Signals a failure by throwing an exception object.

Formal Syntax & Structure

csharp syntaxcsharp
throw new InvalidOperationException("Unavailable");

Working Example

Example Snippetcsharp
throw new ArgumentOutOfRangeException(nameof(quantity));
C# & .NET Reference