我一直在试图写我自己的自定义构造函数,但得到有关base()
构造函数的错误。我也一直在寻找如何解决这个错误,但没有发现任何东西,网络上的所有例子都显示了和我的几乎相同的代码。自定义异常和基构造器
全Exception.cs内容:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace RegisService
{
public class Exceptions : Exception
{
}
public class ProccessIsNotStarted : Exceptions
{
ProccessIsNotStarted()
: base()
{
//var message = "Formavimo procesas nestartuotas";
//base(message);
}
ProccessIsNotStarted(string message)
: base(message) {}
ProccessIsNotStarted(string message, Exception e)
: base(message, e) {}
}
}
与base()
第一超负荷工作,没有错误被抛出。第二和第三 重载告诉我,:
"RegisService.Exceptions does not contain a constructor that takes 1(2) arguments"
我一直在试图解决这个错误还有一个办法:
ProccessIsNotStarted(string message)
{
base(message);
}
ProccessIsNotStarted(string message, Exception e)
{
base(message, e);
}
这个时候,VS是告诉我,:
"Use of keyword 'base' is not valid in this context"
那么,问题在哪里?看起来像base()
构造函数有一些奇怪的重载,或者我用不恰当的方式调用它?
谢谢,它有帮助。我只需为每个'Exceptions'超载添加'public'。 – Masius 2013-02-11 12:06:14