hi can any one tell me how to write user defined exceptions in C#?As we have in Java can we write in C#?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is practically the same as it is in Java – you extend the
Exceptionclass.In the most basic form.
To this, then add the data that you want to capture using either fields or properties.
Out of interest, before answering this question, I checked the Microsoft Design Guildlines on Custom Exceptions. Designing Custom Exceptions (MSDN)
ArgumentException. HOWEVER Do not derive fromApplicationException. It is not harmful, it is no point in doing so. MSDN Blog Post on ApplicationException.ISerializableinterface. Apparently an exception must be serializable to work correctly across application domain and remoting boundaries.I highly recommend reading the Design Guidelines on MSDN.