Skip to content

Instantly share code, notes, and snippets.

@koike koike/extMethod2.cs
Last active Dec 13, 2015

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
static class Program
{
static void Main(string[] args)
{
var array = new List<int>() { 0, 1, 2, 3, 4 };
Console.WriteLine(string.Join(", ", array));
Console.WriteLine(string.Join(", ", array.ExtensionMethod(i => i*2)));
}
}
static class ExtMethod
{
public static List<int> ExtensionMethod(this List<int> array, Func<int, int> lamda)
{
return array.Select(lamda.Invoke).ToList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.