Created
March 26, 2015 12:49
-
-
Save thedom85/4bf549aee8836e56ab83 to your computer and use it in GitHub Desktop.
CSharp_Functional_programming_for_Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
//for (Int32 i = 0; i < 10; i++) Console.WriteLine(i); | |
ExampleFunctiona.ForEach(Enumerable.Range(0, 10), View); | |
} | |
public void View (int i) | |
{ | |
Console.WriteLine(i); | |
} | |
public static class ExampleFunctiona | |
{ | |
public static void ForEach<T>(IEnumerable<T> element, Action<T> run) | |
{ | |
foreach (T item in element) | |
run(item); | |
} | |
} | |
public static class Enumerable | |
{ | |
public static IEnumerable<int> Range(int da,int a) | |
{ | |
List<int> lst = new List<int> (); | |
for (int i = da; i <= a; i++){ | |
lst.Add(i); | |
} | |
return lst; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment