Beispiel #1
0
        static void Main(string[] args)
        {
            // Here is an example that uses a lambda expression to
            //  determine if a value is within a specified range:
            DelRange rangeOK = (low, high, val) => (val >= low && val <= high);

            // After doing so, the lambda expression can be executed as shown here:
            if (rangeOK(10, 15, 3))
            {
                Console.WriteLine("3 is within the range.");
            }
            else
            {
                Console.WriteLine("3 is not within the range.");
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Here is an example that uses a lambda expression to
            //  determine if a value is within a specified range:
            DelRange rangeOK = (low, high, val) => (val >= low && val <= high);

            // After doing so, the lambda expression can be executed as shown here:
            if (rangeOK(10, 15, 3))
            {
                Console.WriteLine("13 is within the range.");
            }
            else
            {
                Console.WriteLine("13 is not within the range.");
            }

            // TODO:...
            // Define a lambda expression which calculate the average of three values
            // And Define corresponding delegate
        } // end main()