※ 引述《GoalBased (Artificail Intelligence)》之铭言:
: 大概是长这样,细节有错的话自己改,
: 是说..现在的新手会开档读档,会用类别,不会用function是怎么回事= =
感谢帮忙,我试着改成这样
private void button1_Click(object sender, EventArgs e)
{
System.IO.StreamReader file = new System.IO.StreamReader("file.txt");
string str = file.ReadLine();
if (str == "father")
{
ClassFather xxx = new ClassFather();
IamFunction(file, xxx);
}
else if (str == "son")
{
ClassSon xxx = new ClassSon();
IamFunction(file, xxx);
}
}
private void IamFunction(System.IO.StreamReader file, ClassFather xxx)
{
xxx.strA = file.ReadLine();
xxx.strB = file.ReadLine();
}
似乎是可以了@@