Пример #1
0
    public static void Main(String[] args)
    {
        LinkedList <double> dLst = new LinkedList <double>(7.0, 9.0, 13.0, 0.0);

        foreach (double d in dLst)
        {
            Console.Write("{0} ", d);
        }
        Console.WriteLine();
        IMyList <int> iLst = dLst.Map <int>(Math.Sign);

        foreach (int i in iLst)
        {
            Console.Write("{0} ", i);
        }
        Console.WriteLine();
        IMyList <String> sLst1 =
            dLst.Map <String>(delegate(double d) { return("s" + d); });

        foreach (String s in sLst1)
        {
            Console.Write("{0} ", s);
        }
        Console.WriteLine();
        IMyList <String> sLst2 = dLst.Map <String>(d => "s" + d);

        foreach (String s in sLst2)
        {
            Console.Write("{0} ", s);
        }
        Console.WriteLine();
        // Testing SortedList<MyString>
        SortedList <MyString> sortedLst = new SortedList <MyString>();

        sortedLst.Insert(new MyString("New York"));
        sortedLst.Insert(new MyString("Rome"));
        sortedLst.Insert(new MyString("Dublin"));
        sortedLst.Insert(new MyString("Riyadh"));
        sortedLst.Insert(new MyString("Tokyo"));
        foreach (MyString s in sortedLst)
        {
            Console.Write("{0}   ", s.Value);
        }
        Console.WriteLine();
        // MyList equality
        Console.WriteLine(dLst.Equals(dLst));   // True
        Console.WriteLine(dLst.Equals(sLst1));  // False
        Console.WriteLine(sLst1.Equals(sLst2)); // True
        Console.WriteLine(sLst1.Equals(null));  // False
    }