Sometimes, in your own program, you have to create exceptions by yourself. No, not to take revenge on the user, but for the sake of your application. Sometimes, there are situations where you need to throw an exception to bypass a difficulty, to log something, or just redirect the flow of the software. Don't worry: by doing this you are not becoming the bad guy; you are actually the hero who is saving the program from trouble. But how can you create an exception? To do that, C# has a keyword called throw. This keyword will help you to create an instance of a type of exception and throw it. Let me show you an example of the throw keyword:
using System;
namespace ExceptionCode
{
class Program
{
public static void Main(string[] args)
{
try
{
Console.WriteLine("You are the boss!");
throw new DivideByZeroException();
}
catch (IndexOutOfRangeException...