예제 #1
0
        static void Main(string[] args)
        {
            GenericList <int> list = new GenericList <int>();

            for (int x = 0; x < 10; x++)
            {
                int a = 0;
                if (int.TryParse(Console.ReadLine(), out a))
                {
                    list.Add(a);
                }
                else
                {
                    Console.WriteLine("请输入整数!");
                }
            }
            list.ForEach(x => Console.WriteLine(x));
            int sum = 0;

            list.ForEach(x => { sum += x; });
            int max = list.Head.Data;

            list.ForEach(x => { max = x > max ? x : max; });
            int min = list.Head.Data;

            list.ForEach(x => { min = x < min ? x : min; });
            Console.WriteLine(sum);
            Console.WriteLine(max);
            Console.WriteLine(min);
            while (true)
            {
                ;
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            GenericList <int> list = new GenericList <int>();
            int          sum       = 0;
            int          max       = -99999999;
            int          min       = 99999999;
            Action <int> Action1   = m => Console.WriteLine(m);
            Action <int> Action2   = m => sum += m;
            Action <int> Action3   = m => { if (m > max)
                                            {
                                                max = m;
                                            }
            };
            Action <int> Action4 = m => { if (m < min)
                                          {
                                              min = m;
                                          }
            };

            list.ForEach(Action1);
            list.ForEach(Action2);
            list.ForEach(Action3);
            list.ForEach(Action4);
        }