static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; Thread.CurrentThread.CurrentUICulture = new CultureInfo("bg-BG"); // Assigning the Video Cards Components mcardVLC = new Motherboard("VLC",(decimal)185.89); Components vcardRadeon = new GraphicCard("Radeon",(decimal)102.34,"onr of the best"); Components vcardGeForce = new GraphicCard("GeForce",(decimal)156.89,"no good"); // Assigning the Processors Components proIntel = new Processor("Intel",(decimal)347.667,"no bad"); Components proAMD = new Processor("AMD",(decimal)405.239,"the best"); // Computers Computer compAMDRadeon = new Computer("Fasty", new List<Components>() { mcardVLC,vcardRadeon,proAMD}); Computer compIntelGeForce = new Computer("Star"); compIntelGeForce.Components.Add(vcardGeForce); compIntelGeForce.Components.Add(mcardVLC); List<Computer> computers = new List<Computer> { compIntelGeForce,compAMDRadeon }; computers.OrderBy(c => c.Price).ToList().ForEach(c => Console.WriteLine(c.ToString())); }
static void Main(string[] args) { Computer asus = new Computer("Asus",new Component("inel7","cpu",123.5M),23.5M); Computer asus1 = new Computer("Asus", new Component("inel8", "", 1123.5M), 23.5M); asus1.SeveralComponents.Add(new Component("inel7", "cpu", 123.5M)); Computer asus2 = new Computer("Asus", new Component("inel9", "cpu", 1129.5M), 23.5M); List<Computer> computers = new List<Computer>(); computers.Add(asus); computers.Add(asus1); computers.Add(asus2); var result = computers.OrderBy(x => x.Price); foreach (var item in result) { Console.WriteLine(item); } }