代码拉取完成,页面将自动刷新
public class Student : IComparable
{
public double mygrade;
public string mysubject, myID;
public Student() { }
public Student(double grade, string subject, string id)
{
mygrade = grade;
mysubject = subject;
myID = id;
}
int IComparable.CompareTo(Object obj)
{
if (obj is Student)
{
Student castObj = (Student)obj;
if (this.mygrade > castObj.mygrade) return 1;
else if (this.mygrade < castObj.mygrade) return -1;
else return 0;
}
throw new ArgumentException("object is not a Student");
}
}
internal class Program
{
private static void Main(string[] args)
{
Student[] students = new Student[5];
students[0] = new Student(50.0, "windows程序设计", "001");
students[1] = new Student(90.0, "windows程序设计", "002");
students[2] = new Student(100.0, "windows程序设计", "003");
students[3] = new Student(70.0, "windows程序设计", "004");
students[4] = new Student(80.0, "windows程序设计", "005");
Array.Sort(students);
foreach (Student student in students)
{
Console.WriteLine(student.mygrade + " " +student.mysubject + " " + student.myID);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。