User define exception class

Total Post:101

Points:709
C# 
C#
 1090  View(s)
Ratings:
Rate this:
Hi Guys

Can someone tell me a small example for custom (User define ) exception class.

Thanks
  1. Post:100

    Points:700
    Re: User define exception class

    Hello Pravesh Singh!
    Below I Provide you a demo code for user define exception class.

    using System;
    namespace MindstickCustomeExceptionDemo
    {
        public class MindstickEmployeeListNotFoundException : Exception
        {
            public MindstickEmployeeListNotFoundException()
            {
            }
            public MindstickEmployeeListNotFoundException(string message)
                : base(message)
            {
            }
        }
        class CustomException
        {
            static void Main(string[] args)
            {
                try
                {
                    throw new MindstickEmployeeListNotFoundException("\n\n::Mindstick Employee List not found::\n\n");
                }
                catch (MindstickEmployeeListNotFoundException ce)
                {
                    Console.WriteLine(ce.ToString());
                }
                Console.ReadKey();
            }
        }
    }


     If you want to more knowledge about User define exception class read this link

     

     

      Modified On Mar-30-2018 03:33:03 AM

Answer