Home > DeveloperSection > Forums > User define exception class
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    June-13-2013 4:10 AM

 C# C# 
Ratings:


 1 Reply(s)
 690  View(s)
Rate this:
Hi Guys

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

Thanks


Vijay Shukla

Total Post:100

Points:700
Posted on    June-13-2013 7:11 AM

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

 

 


Don't want to miss updates? Please click the below button!

Follow MindStick