Class Program
{
Define a struct body
struct Student//student is the new data type we made ourselves.
{
public int Code;//public modifier
public string name;//member of struct body
public decimal height;
}
static void Main (string[] args)
{
ArrayList arr = new ArrayList ();
for (int i = 0; i < 3; i++)
{
Student s = new student ();//define struct-body variables
Console.Write ("Study No.:");
S.code = Int. Parse (Console.ReadLine ());
Console.Write ("Name:");
S.name = Console.ReadLine ();
Console.Write ("Height:");
S.height = Decimal. Parse (Console.ReadLine ());
Arr. ADD (s);
}
for (int i = 0; i < 2; i++)
{
for (int j = i + 1; j < 3; J + +)
{
Student si = (student) arr[i];
Student SJ = (student) arr[j];
if (Si.height < sj.height)
{
Student Zhong = si;
Arr[i] = Arr[j];
ARR[J] = Zhong;
}
}
}
foreach (student s in arr)
{
Console.WriteLine (S.code + "+ s.name +" "+ s.height);
}
Console.ReadLine ();
}
}
C # defines a student's structure, enter student information, study number, name, height, sort output by height