见下面的程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication13
{
// Student结构
struct Student
{
// 姓名
public string Name;
// 学号
public int ID;
// 成绩
public float Score;
public override string ToString()
{
return string.Format("姓名:{0},学号:{1},成绩:{2}",
Name,
ID,
Score);
}
}
class Program
{
static void Main(string[] args)
{
// 学生结构数组
Student[] students = new Student[5];
students[0] = new Student { Name = "张三", ID = 1, Score = 90 };
students[1] = new Student { Name = "李四", ID = 2, Score = 80 };
students[2] = new Student { Name = "
王五", ID = 3, Score = 70 };
students[3] = new Student { Name = "赵六", ID = 4, Score = 60 };
students[4] = new Student { Name = "钱七", ID = 5, Score = 50 };
// 输出
for (int i = 0; i < students.Length; i++)
{
Console.WriteLine(students[i].ToString());
}
}
}