public class Person : IPrint, IComparable
Console.WriteLine("{0}\n{1}", name, age);
public int CompareTo(object obj)
Person point = (Person)obj;
return age.CompareTo(point.age);
public Person(string name, int age)
public T Min<T>(T x, T y) where T : IComparable
public void Swap<T>(ref T x, ref T y)
public static void Main()
Person[] arr = new Person[5];
Person firstObj = new Person();
for (int i = 0; i < arr.Length; i++)
arr[i] = new Person("П" + (char)(i + 65), i + 110);
firstObj.Swap(ref arr[0].age, ref arr[1].age);
firstObj.Swap(ref arr[0].name, ref arr[1].name);
for (int i = 0; i < arr.Length - 1; i++)
Console.WriteLine(firstObj.Min(arr[i].age, arr[i + 1].age));