public void button2_Click(object sender, System.EventArgs e)
{
string text = textBox1.Text;
Mainform = this;
this.Hide();
GetSchedule myScheduleFinder = new GetSchedule();
string result = myScheduleFinder.GetDataFromNumber(text);// says there is no definition
if (!string.IsNullOrEmpty(result))
{
MessageBox.Show(result);
}
else
{
MessageBox.Show("Enter A Valid ID Number!");
}
}
говорит, что он не содержит определения для него, но в моем файле GetSchedule .cs я определил его
public string GetDataFromNumber(string ID)//defined here
{
foreach (IDnumber IDCandidateMatch in IDnumbers)
{
if (IDCandidateMatch.ID == ID)
{
StringBuilder myData = new StringBuilder();
myData.AppendLine(IDCandidateMatch.Name);
myData.AppendLine(": ");
myData.AppendLine(IDCandidateMatch.ID);
myData.AppendLine(IDCandidateMatch.year);
myData.AppendLine(IDCandidateMatch.class1);
myData.AppendLine(IDCandidateMatch.class2);
myData.AppendLine(IDCandidateMatch.class3);
myData.AppendLine(IDCandidateMatch.class4);
//return myData;
return myData.ToString();
}
}
return "";
}
Класс GetSchedule
открытый класс GetSchedule
{
public GetSchedule ()
{
IDnumber [] IDnumbers = новый IDnumber [3];
IDnumbers [0] = новый IDnumber () {Имя = "Джошуа Бэнкс", ID = "900456317", год = "Старший", класс1 = "TEET 4090", class2 = "TEET 3020", class3 = "TEET 3090", class4 = "TEET 4290"};
IDnumbers [1] = новый IDnumber () {Name = "Шон Уорд", ID = "900456318", год = "младший", class1 = "ENGNR 4090", class2 = "ENGNR 3020", class3 = "ENGNR 3090", class4 = "ENGNR 4290"};
IDnumbers [2] = новый IDnumber () {Name = "Террелл Джонсон", ID = "900456319", год = "второкурсник", class1 = "BUS 4090", class2 = "BUS 3020", class3 = "BUS 3090", class4 = "BUS 4290"};
}
public class IDnumber
{
public string Name { get; set; }
public string ID { get; set; }
public string year { get; set; }
public string class1 { get; set; }
public string class2 { get; set; }
public string class3 { get; set; }
public string class4 { get; set; }
public static void ProcessNumber(IDnumber myNum)
{
StringBuilder myData = new StringBuilder();
myData.AppendLine(myNum.Name);
myData.AppendLine(": ");
myData.AppendLine(myNum.ID);
myData.AppendLine(myNum.year);
myData.AppendLine(myNum.class1);
myData.AppendLine(myNum.class2);
myData.AppendLine(myNum.class3);
myData.AppendLine(myNum.class4);
MessageBox.Show(myData.ToString());
}
public string GetDataFromNumber(string ID)
{
IDnumber[] IDnumbers = new IDnumber[3];
foreach (IDnumber IDCandidateMatch in IDnumbers)
{
if (IDCandidateMatch.ID == ID)
{
StringBuilder myData = new StringBuilder();
myData.AppendLine(IDCandidateMatch.Name);
myData.AppendLine(": ");
myData.AppendLine(IDCandidateMatch.ID);
myData.AppendLine(IDCandidateMatch.year);
myData.AppendLine(IDCandidateMatch.class1);
myData.AppendLine(IDCandidateMatch.class2);
myData.AppendLine(IDCandidateMatch.class3);
myData.AppendLine(IDCandidateMatch.class4);
//return myData;
return myData.ToString();
}
}
return "";
}
} * +1010 *
}
}