USER DEFINE EXCEPTION CLASS

Pravesh Singh

Total Post:101

Points:709
Posted by  Pravesh Singh
C# 
C#
 869  View(s)
Ratings:
Rate this:
Hi Guys

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

Thanks
  1. Vijay Shukla

    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

     

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!