public class Product : IComparable<Product>
public Product(string type, string name, double price)
public void Print(string type, string name, double price)
Console.WriteLine("Тип товара: {0}\tНазвание: {1}\tЦена:{2}", type, name, price);
public int CompareTo(Product other)
return price.CompareTo(other.price);
public class Container<T>
for (int i = 0; i < count; i++)
Console.WriteLine(array[i]);
public void Push(T value)
if (count < array.Length)
count -= count > 0 ? 1 : 0;
public static void Print<T>(T[] array)
for (int i = 0; i < array.Length; i++)
Console.Write("{0}\t",array[i]);
public static int CompareIt<T>(T[] arr, T value) where T : IComparable<T>
for (int i = 0; i < arr.Length; i++)
if (arr[i].CompareTo(value) == 0)
public static void Main()
double[] arr = new double[5];
for (int i = 0; i < arr.Length; i++)
Container<double> containerObject = new Container<double>();
containerObject.Push(55);
Product obj = new Product();
Product[] products = new Product[5];
for (int i = 0; i < products.Length; i++)
products[i] = new Product("Г" + (char)192 + i, "П" + (char)192 + i, 100 - i * 3);
Console.WriteLine("\nМассив до сортировки:");
for (int i = 0; i < products.Length; i++)
obj.Print(products[i].type, products[i].name, products[i].price);
Console.WriteLine("\nМассив после сортировки:");
for (int i = 0; i < products.Length; i++)
obj.Print(products[i].type, products[i].name, products[i].price);