Using outter variable

lambda expression can use outter variable.

 
using System;


class Program
{
    public static void Main()
    {
        int factor = 2;
        Func<int, int> multiplier = n => n * factor; 
        Console.WriteLine(multiplier(3));
    }
}

The output:


6
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.