Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace LambdaTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> foo = new List<string>()
- {
- "Hello", "World", "C# is awesome!"
- };
- foo.DoForEach(x => Console.WriteLine(x));
- }
- }
- public static class Extensions
- {
- public static void DoForEach<T>(this List<T> l, Action<T> a)
- {
- foreach (T t in l)
- {
- a(t);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment