ArgumentOutOfRangeException
The .NET exception to throw when an argument's value is outside what a method accepts, such as a negative price.
In more detail
Throwing it early, in a guard clause, stops a bad value travelling further into the program. Pass nameof(parameter) so the message names the argument, and the name stays right after a rename.
Related terms
- exception — An error object a program raises to stop normal flow and report that something went wrong.
- nameof — The C# operator that turns a symbol into its name as a string, as in nameof(price) giving "price".
Taught in
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices