xiaolizi007
6/5/2017 - 2:56 AM

lambda demo , delegate的用法

lambda demo , delegate的用法 #csharp

            Action<int> printRoot = delegate(int number)
            {
                Console.WriteLine(Math.Sqrt(number));
            };
            
            
            
                     Action<IList<double>> printMean = delegate(IList<double> numbers)
            {
                double total = 0;
                foreach (double value in numbers)
                {
                    total += value;
                }
                Console.WriteLine(total / numbers.Count);
            };