Setting the message of a custom Exception without passing it to the base constructor

后端 未结 5 1273
悲&欢浪女
悲&欢浪女 2021-02-11 12:20

I want to make a custom Exception in C#, but in theory I do need to do a little parsing first before I can make a human readable ExceptionMessage.

The problem is that th

5条回答
  •  时光说笑
    2021-02-11 12:56

    I like to use this here. It is easy and does not need the static function:

    public class MyException : Exception
    {
        public MyException () : base("This is my Custom Exception Message")
        {
        }
    }
    

提交回复
热议问题