Program.cs 1.63 KB
Newer Older
Uwe Wienkop's avatar
Uwe Wienkop committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;

namespace _06GenericList
{
    class Person : IComparable<Person>
    {
        string name, vorname;
        public Person(string name, string vorname)
        {
            this.name = name;
            this.vorname = vorname;
        }
        public int CompareTo(Person other)
        {
            return (name + vorname).CompareTo(other.name + other.vorname);
        }
        public override string ToString()
        => $"{name}, {vorname}";
    }
    class Program
    {
        static void Main(string[] args)
        {
            Liste<int> il = new Liste<int>();
            il.AddEnd(10);
            il.AddEnd(20);
Uwe Wienkop's avatar
Uwe Wienkop committed
27
28
29
30
31
32
33
34
35
            il.AddEnd(23);
            il.AddEnd(21);
            il.AddEnd(35);
            il.AddEnd(40);
            foreach (var item in il.Filter(x => x%2==0))
            {
                Console.WriteLine(item);
            }
            //il.Print();
Uwe Wienkop's avatar
Uwe Wienkop committed
36

Uwe Wienkop's avatar
Uwe Wienkop committed
37
            Console.WriteLine("*****************");
Uwe Wienkop's avatar
Uwe Wienkop committed
38
39
40
            Liste<string> sl = new Liste<string>();
            sl.AddSorted("Emil");
            sl.AddSorted("Anton");
Uwe Wienkop's avatar
Uwe Wienkop committed
41
42
43
44
45
46
47
            sl.AddSorted("Berta");
            sl.AddSorted("Dieter");
            foreach (var item in sl.Filter(x=>x.Contains("er")))
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("*****************");
Uwe Wienkop's avatar
Uwe Wienkop committed
48
49
50
51
52
53
54
55
            sl.Print();

            Liste<Person> pl = new Liste<Person>();
            pl.AddSorted(new Person("Meier", "Emil"));
            pl.AddSorted(new Person("Schmitt", "Anton"));
            pl.Print();

            Liste<Liste<Person>> pll = new Liste<Liste<Person>>();
Uwe Wienkop's avatar
Uwe Wienkop committed
56
            pll.AddSorted(pl);
Uwe Wienkop's avatar
Uwe Wienkop committed
57
58
59
60
        }

    }
}