In C# how do I define my own Exceptions?

前端 未结 8 2073
北荒
北荒 2020-12-07 23:51

In C# how do I define my own Exceptions?

8条回答
  •  感动是毒
    2020-12-08 00:42

    Definition:

    public class CustomException : Exception
    {
       public CustomException(string Message) : base (Message)
       {
       }
    }
    

    throwing:

    throw new CustomException("Custom exception message");
    

提交回复
热议问题