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
w___ww___.___ja__v___a2__s__._c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.