예제 #1
0
        private static void ShowAdd()
        {
            var collec1 = new PersonsCollection <Person>(lstPers);

            collec1.Added(new Person("test", "test", 2));
            collec1.Reset();
            foreach (var element in collec1)
            {
                Console.WriteLine(element.Name + " " + element.Surname + " " + element.Age);
            }
        }
예제 #2
0
        private static void DeletePerson()
        {
            var collec = new PersonsCollection <Person>(lstPers);
            var pers   = collec.FirstOrDefault(person => person.Age <= 10);

            if (pers != null)
            {
                collec.Removed(pers);
            }
            collec.Reset();
            foreach (var element in collec)
            {
                Console.WriteLine(element.Name + " " + element.Surname + " " + element.Age);
            }
        }
예제 #3
0
        private static void SortBuble()
        {
            List <Person> lstPers = new List <Person>();

            lstPers.Add(new Person("Roma", "Gapunich", 26));
            lstPers.Add(new Person("Dyma", "Hulyi", 21));
            lstPers.Add(new Person("Bogdan", "Magda", 32));
            lstPers.Add(new Person("Vitaliy", "VitaliySyrname", 4112));
            lstPers.Add(new Person("Rosadsdma", "Gasdasdapunich", 226));
            lstPers.Add(new Person("Dyma", "Hasdasdulyi", 221));
            lstPers.Add(new Person("Basdasdogdan", "Maasdasdgda", 324));
            lstPers.Add(new Person("Vitasdasdaliy", "VitaliySyrname", 12123));
            var test = new PersonsCollection <Person>(lstPers);

            test.Sort((v1, v2) => v1.Age < v2.Age);

            foreach (var value in test)
            {
                Console.WriteLine(value.Name + " " + value.Surname + " " + value.Age);
            }
        }