简体   繁体   中英

C# Constructor throwing error

I am writing a program to clean up some database records. I created a GUI to be able to both search the records and to edit them (there are over 100,000 records). I created a Record object with 5 parameters. I also created a Constuctor that takes in those 5 parameters. Yet everytime I build my program, it throws two errors saying "WorkDataCleaner.Record does not contain a constructor that takes 5 arguments".

Here is my Record class and constructor:

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;
    }


}

Here is my code where I call Record (both are throwing errors):

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);

I am calling Record from an event handler of my GUI. I also call Record from a different class outside of my event handlers and it is fine. Whenever I retype the code the errors go away but once i rebuild it, the errors come back. Not sure what the problem is.

Perhaps you could try rebuilding your program? I just copied and pasted your class and the calls to your constructor and didn't get this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM