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文件我把它定义不包含GetDataFromNumber的定义但是我已经定义了它?
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 { 公共GetSchedule(){ IDnumber [] IDnumbers =新ID号[3]; IDnumbers [0] = new IDnumber(){Name =“Joshua Banks”,ID =“900456317”,year =“Senior”,class1 =“TEET 4090”,class2 =“TEET 3020”,class3 =“TEET 3090” ,class4 =“TEET 4290”}; IDnumbers [1] = new IDnumber(){Name =“Sean Ward”,ID =“900456318”,year =“Junior”,class1 =“ENGNR 4090”,class2 =“ENGNR 3020”,class3 =“ENGNR 3090” ,class4 =“ENGNR 4290”}; IDnumbers [2] = new IDnumber(){Name =“Terrell Johnson”,ID =“900456319”,year =“Sophomore”,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 "";
}}
}
}
对不起,你需要改变你的问题,一点也不清楚。 – 2010-04-27 21:32:34
即时通讯对不起,我得到一个错误,说GetDataFromNumber没有定义,不接受类型的第一个参数....但GetDataFromNumber在另一个.cs文件中的第二组代码中使用/定义...我能做些什么来纠正这个!?! – 2010-04-27 21:38:26
你确实有一个名为GetSchedule的类吗?如果是这样,将这个定义包含在问题中可能会有所帮助。 – 2010-04-27 21:40:27