Create a lambda from Func in CSharp

Description

The following code shows how to create a lambda from Func.

Example


   /*ww  w .  j a  v  a  2s  . c  o  m*/

using System;

class Test {
    static void Main() {
        Func<int, int> square = x => x * x;
        Console.WriteLine(square(3));     // 9
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Custom Types »




C# Class
C# Struct
C# Interface
C# Inheritance
C# Namespace
C# Object
C# Delegate
C# Lambda
C# Event
C# Enum
C# Attribute
C# Generics
C# Preprocessor