Question #256571

Create a user defined class for Exception for age, if age is negative throw an exception that age cannot be less than zero?


Expert's answer

using System;
using System.Collections.Generic;


namespace App
{


    class AgeException:Exception{
        public AgeException()
            : base("Age cannot be less than zero")
        {
            
        }
    }




    class Program
    {


        static void Main(string[] args)
        {
          
            
            Console.ReadLine();
        }
    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS