public class ExceptionUndefinedEnumConditions : Exception
    {
        public ExceptionUndefinedEnumConditions(Type type)
        {
            if (type != null)
            {
                base.Message = type.ToString();
            }
            else
            {
                this.Message = "Type Undefined";
            }        }
    }我要自定义一个错误,然后传一个Type进来,但我上面的定法不行
应该如何写?
谢谢

解决方案 »

  1.   

    除了下面写的方法,还有其他方法吗?        public ExceptionUndefinedEnumConditions(Type type)
                : base(type != null ? type.ToString() : "Type Undefined")
            {        }
      

  2.   

    你现在什么问题 base.Message 是只读的,不能赋值
      

  3.   


     public class ExceptionUndefinedEnumConditions : Exception
        {
            public new string Message
            {
                get;
                set;
            }        public ExceptionUndefinedEnumConditions(Type type)
            {           
                if (type != null)
                {
                    this.Message = type.ToString();
                }
                else
                {
                    this.Message = "Type Undefined";
                }
            }
        }