Example #1
0
        static void Main(string[] args)
        {
            CollectionType<Tor> collectionType_1 = new CollectionType<Tor>();
            Tor tor1 = new Tor("ator",10, 80);
            Tor tor2 = new Tor("btor",20, 90);
            Tor tor3 = new Tor("btor",30, 70);
            collectionType_1.Add(tor1);
            collectionType_1.Add(tor2);
            collectionType_1.Add(tor3);
            foreach (Tor value in collectionType_1)
                value.printInfo();
            WriteToFile(collectionType_1);

            collectionType_1.SortT();
            foreach (Tor value in collectionType_1)
                value.printInfo();

            CollectionType<Tor> collectionType_2 = new CollectionType<Tor>();
            Tor tor4 = new Tor("dtor",50, 80);
            Tor tor5 = new Tor("etor",20, 100);
            Tor tor6 = new Tor("ftor",30, 70);


            var linkedList = new LinkedList<CollectionType<Tor>>();
            linkedList.AddLast(collectionType_1);
            linkedList.AddFirst(collectionType_2);


            Console.WriteLine("where + OrderBy");
            var selectedTeams = collectionType_1.Where(t => t.Name.ToUpper().StartsWith("B")).OrderBy(t => t);
            foreach (Tor s in selectedTeams)
                s.printInfo();

            Console.WriteLine("Where( || + && + > )");
            var selectedTeams_2 = collectionType_1.Where(t => (t.innerRadius < 100 || t.outerRadius > 70) && t.innerRadius > 20);
            foreach (Tor s in selectedTeams_2)
                s.printInfo();

            Console.WriteLine("Where+Count");
            var selectedTeams_3 = (collectionType_1.Where(s => s.innerRadius < 90)).Count();
            Console.WriteLine(selectedTeams_3);

            Console.WriteLine("Select");
            var selectedTeams_4 = collectionType_1.Select((h, i) => new { Index = i + 1, h.Name });
            foreach (var el in selectedTeams_4)
                Console.WriteLine(el);


            Console.WriteLine("Min");
            var minRes = collectionType_1.Min(h => h.outerRadius);
            Console.WriteLine(minRes);

            Console.WriteLine("Max");
            var maxRes = collectionType_1.Max(h => h.outerRadius);
            Console.WriteLine(maxRes);

            Console.WriteLine("Join");
            var joinRes = collectionType_1.Join(collectionType_2, o => o.innerRadius, i => i.innerRadius, (o, i) => new Tor
            {
                Name = string.Format("{0}&{1}",o.Name,i.Name),
                innerRadius = o.innerRadius + i.innerRadius,
                outerRadius = o.outerRadius + i.outerRadius
            });
            foreach (var tor in joinRes)
                Console.WriteLine(tor);


            LinkedList<string> stringList = new LinkedList<string>();
            stringList.AddFirst("ЯАнтон");
            stringList.AddFirst("Саня");
            stringList.AddLast("Александр");
            WriteToFile(stringList);
            foreach (var value in stringList) Console.WriteLine("Значение: "+value);
            includeWord(stringList, "Саня");
            Console.WriteLine(lenghtString(stringList, 4));


            //var asc = stringList.OrderBy(v => v).ToList();
            var asc = stringList.OrderBy(v=>v);
            foreach (var value in asc) Console.WriteLine("Значение: " + value);
            Console.WriteLine("\n");
            var desc = stringList.OrderByDescending(v=>v);
            foreach (var value in desc) Console.WriteLine("Значение: " + value);

            Console.ReadKey();

        }