Source Code:-
using System;
class NoMatchException : Exception
{
public NoMatchException()
{
}
public NoMatchException(string str) : base(str)
{
}
}
class Demo
{
static void Main(string[] args)
{
string str;
Console.WriteLine("Enter the string");
str = Console.ReadLine();
try {
if (str != "India")
{
throw new NoMatchException("No Match");
}
else
{
Console.WriteLine("Match");
}
}
catch (NoMatchException n)
{
Console.WriteLine(n);
}
Console.ReadKey();
}
}
0 Comments