Beispiel #1
0
        static void AngleOp()
        {
            //Initializing
            Angles[] a = new Angles[] { new Angles(359, 51, 23), new Angles(0, 0, 1000), new Angles(5, 20, 10), new Angles(3, 40, 50) };

            //Sorting Angles by degrees
            var b = a.OrderBy(x => x.degrees).ToList();

            //Show data sorted by degrees
            WriteLine("Sorting Angles by degrees:");
            foreach (Angles w in b)
            {
                WriteLine(w.degrees + "* " + w.minutes + "' " + w.seconds + "''");
            }

            //IComparable example(CompareTo)
            Sort(a);

            WriteLine("Sorting Angles by seconds:");
            foreach (Angles w in a)
            {
                WriteLine(w.degrees + "* " + w.minutes + "' " + w.seconds + "''");
            }

            //IComparer example (Comparer)
            Sort(a, new AnglesComparer());

            WriteLine("Sorting Angles by minutes:");
            foreach (Angles w in a)
            {
                WriteLine(w.degrees + "* " + w.minutes + "' " + w.seconds + "''");
            }

            //Show Sum of degrees, minutes and seconds
            Angles c = new Angles();

            c = c.Sum(a);

            WriteLine();
            WriteLine(c.degrees + "* " + c.minutes + "' " + c.seconds + "'' ");
        }