C#构造函数抛出错误

时间:2013-05-23 18:23:20

标签: c# user-interface

我正在编写一个程序来清理一些数据库记录。我创建了一个GUI,能够搜索记录并编辑它们(有超过100,000条记录)。我用5个参数创建了一个Record对象。我还创建了一个Constuctor,它接收了这5个参数。然而,每次我构建我的程序时,它都会抛出两个错误,说“WorkDataCleaner.Record不包含带有5个参数的构造函数”。

这是我的Record类和构造函数:

public class Record
{
    public string[] CatalogNumbers;
    public string CultRegion;
    public string Culture;
    public string[] SiteLocality;
    public string ObjectName;

    /// <summary>
    /// Parameters that builds a Record Object
    /// </summary>
    /// <param name="CatalogNumbers"></param>
    /// <param name="CultRegion"></param>
    /// <param name="Culture"></param>
    /// <param name="SiteLocality"></param>
    /// <param name="ObjectName"></param>
    public Record(string[] CatalogNumbers, string CultRegion, string Culture, string[] SiteLocality, string ObjectName)
    {
        this.CatalogNumbers = CatalogNumbers;
        this.CultRegion = CultRegion;
        this.Culture = Culture;
        this.SiteLocality = SiteLocality;
        this.ObjectName = ObjectName;
    }


}

这是我的代码,我调用Record(两者都抛出错误):

string[] CatalogNumbers;
string CultRegion;
string Culture;
string[] SiteLocality;
string ObjectName;
string[] EditsCatNum;
string EditsCReg;
string EditsCult;
string[] EditsSiteLocality;
string EditsObjectName;

Record Search = new Record(CatalogNumbers, CultRegion, Culture, SiteLocality, ObjectName);
Record Edits = new Record(EditsCatNum, EditsCReg, EditsCult, EditsSiteLocality, EditsObjectName);

我从GUI的事件处理程序调用Record。我也从事件处理程序之外的其他类调用Record,这很好。每当我重新键入代码时,错误就会消失,但一旦重建它,错误就会消失。不确定是什么问题。

1 个答案:

答案 0 :(得分:0)

也许你可以尝试重建你的程序?我只是复制并粘贴了你的类和调用你的构造函数,并没有得到这个错误。