{
public string name;
public int age;
public float weight;
public Student(string a, int b, float c)
{
name = a;
age = b;
weight = c;
}
}
class Test
{
static void Main(string[] args)
{
ArrayList stuarray = new ArrayList();
string tag;
do
{
Console.Write("Enter the name:");
string tmp_name = Console.ReadLine();
Console.Write("Enter the age:");
int tmp_age = int.Parse(Console.ReadLine());
Console.Write("Enter the weight:");
float tmp_weight = float.Parse(Console.ReadLine());
stuarray.Add(new Student(tmp_name, tmp_age, tmp_weight));
Console.WriteLine("Contuine? (y/n)");
tag =Console.WriteLine();
} while (tag == 'y');
int MaxIndex = 0, Maxage = 0;
int i = 0;
for (i = 0; i < stuarray.Count;i++)
{
if ((Student)stuarray[i].age > Maxage)
{
Maxage = (Student)stuarray[i].age;
MaxIndex = i;
}
}
Console.WriteLine("The Name with Maxage is {0}", (Student)stuarray[MaxIndex].name);
}
}
请问一下后面几句有什么错,调试时老出错!说不包括age ,name 的定义!非常感谢!