Guest User

Untitled

a guest
Oct 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace LambdaTest
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. List<string> foo = new List<string>()
  13. {
  14. "Hello", "World", "C# is awesome!"
  15. };
  16.  
  17. foo.DoForEach(x => Console.WriteLine(x));
  18. }
  19. }
  20.  
  21. public static class Extensions
  22. {
  23. public static void DoForEach<T>(this List<T> l, Action<T> a)
  24. {
  25. foreach (T t in l)
  26. {
  27. a(t);
  28. }
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment