...

/

Creating and Throwing Exceptions

Creating and Throwing Exceptions

Learn to create custom exception types and use them inside programs.

We'll cover the following...

Custom exception types

Although there are many built-in exception types in .NET, we might need to create our own based on our application requirements.

Note: The only thing we need to create a custom exception type is a class that inherits from Exception.

Imagine we’re building an application with a login feature. We need to check if the user provides the correct username and password. In the case that their credentials are invalid, we need to generate an exception that informs the user that they’ve provided ...