The code snippet is given as below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomExceptionInCsharp
{
class Program
{
static void Main(string[] args)
{
try
{
int res = checkAGE();
Console.WriteLine(res);
Console.ReadLine();
}
catch (CustomEx_AGE ex)
{
Console.WriteLine(ex.Message);
}
}
static int checkAGE()
{
Console.WriteLine("Enter AGE:");
int age = Convert.ToInt32(Console.ReadLine());
if (age<18 18="" :="" above="" age="" base="" be="" class="" customex_age="" exception="" msg="" new="" pre="" public="" return="" should="" string="" throw="">
18>
0 comments:
Post a Comment