lambda with outer function

In this chapter you will learn:

  1. Using outer variable

Using outer variable

lambda expression can use outer variable.

using System;/*j a  v a 2 s  .co  m*/


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

The output:

Next chapter...

What you will learn in the next chapter:

  1. lambda and iteration variables
Home » C# Tutorial » delegate, lambda, event
delegate
Multicast delegate
delegate variables
delegate parameters
Generic delegate
delegate return
Func and Action
delegate new
chained delegate
Anonymous delegate
delegate array
Return a delegate
delegate as parameter
Event
event multicast
static event
EventHandler
Event pattern
lambda
lambda syntax
Func, Action and lambda
lambda with outer function
lambda iteration variables