主题:[讨论]请教一下,有关类数组的问题
using System;
class Myclass
{
public class Student
{
public string Number, Name;
public int Maths, English, Sum;
}
public static void Data_insert()
{
int Max = 2;
[color=FF0000]Student[] student = new Student[Max];[/color]
for (int i = 0; i < Max; i++)
{
student[i].Number = Console.ReadLine();
student[i].Name = Console.ReadLine();
student[i].Maths = Int32.Parse(Console.ReadLine());
student[i].English = Int32.Parse(Console.ReadLine());
student[i].Sum = student[i].Maths + student[i].English;
}
for (int i = 0; i < Max; i++)
{
Console.WriteLine("{0}", student[i].Number);
Console.WriteLine("{0}", student[i].Name);
Console.WriteLine("{0}", student[i].Maths);
Console.WriteLine("{0}", student[i].English);
Console.WriteLine("{0}", student[i].Sum);
}
}
public static void Main()
{
Data_insert();
}
}
帮忙看下有什么问题,类的数组是这样建的吗?
class Myclass
{
public class Student
{
public string Number, Name;
public int Maths, English, Sum;
}
public static void Data_insert()
{
int Max = 2;
[color=FF0000]Student[] student = new Student[Max];[/color]
for (int i = 0; i < Max; i++)
{
student[i].Number = Console.ReadLine();
student[i].Name = Console.ReadLine();
student[i].Maths = Int32.Parse(Console.ReadLine());
student[i].English = Int32.Parse(Console.ReadLine());
student[i].Sum = student[i].Maths + student[i].English;
}
for (int i = 0; i < Max; i++)
{
Console.WriteLine("{0}", student[i].Number);
Console.WriteLine("{0}", student[i].Name);
Console.WriteLine("{0}", student[i].Maths);
Console.WriteLine("{0}", student[i].English);
Console.WriteLine("{0}", student[i].Sum);
}
}
public static void Main()
{
Data_insert();
}
}
帮忙看下有什么问题,类的数组是这样建的吗?