An delegate instantiated with a lambda - CSharp Custom Type

CSharp examples for Custom Type:Lambda

Description

An delegate instantiated with a lambda

Demo Code


using System;/*from w w w  .ja va  2 s  .c o  m*/
using System.Collections.Generic;
delegate int AgeIsNothing(int n);
class Program
{
    static void Main(string[] args)
    {
        List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
        int[] numArray = numbers.ToArray();
        List<string> words = new List<string> { "one", "two", "three", "four", "five" };

        AgeIsNothing ain = new AgeIsNothing(n => { return n - n; });
        int negligibleAge = ain(15);
        Console.WriteLine("\tFor 15, the nothing age is {0}", negligibleAge);
    }
}

Result


Related Tutorials