using System.Collections.Generic;
public string CarName { set; get; }
public int MaxSpeed { get; set; }
public double Cost { get; set; }
public byte Discount { get; set; }
public int ID { get; set; }
public AutoShop(string CarName, int MaxSpeed, double Cost, byte Discount, int ID)
this.MaxSpeed = MaxSpeed;
this.Discount = Discount;
public override string ToString()
return String.Format("{4}\tName: {0}\tMax speed: {1}\tPrice: {2:C}\tDiscount: {3}%",
this.CarName,this.MaxSpeed,this.Cost,this.Discount,this.ID);
class CompInv<T> : IComparer<T>
public int Compare(T x, T y)
public static void Main()
CompInv<AutoShop> cp = new CompInv<AutoShop>();
List<AutoShop> dic = new List<AutoShop>();
AutoShop[] autoArr = new AutoShop[5];
dic.Add(new AutoShop("Toyota Corolla", 180, 300000, 5, 1));
dic.Add(new AutoShop("VAZ 2114i", 160, 220000, 0, 2));
dic.Add(new AutoShop("Daewoo Nexia", 140, 260000, 5, 3));
dic.Add(new AutoShop("Honda Torneo", 220, 400000, 7, 4));
dic.Add(new AutoShop("Audi R8 Best", 360, 4200000, 3, 5));
Console.WriteLine("Initial car catalog: \n");
foreach (AutoShop a in dic)
Console.WriteLine("\nNow cars are sorted by price: \n");
foreach (AutoShop a in dic)