Created
October 8, 2015 15:39
-
-
Save oguzhaneren/bdbc83aba5bb1accd79d to your computer and use it in GitHub Desktop.
How C# killed the Strategy Pattern
This file contains hidden or 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() | |
| { | |
| Console.WriteLine ("Add: "+Execute(add,3,4)); | |
| Console.WriteLine ("Subtract: "+Execute(subtract,3,4)); | |
| Console.WriteLine ("Multiply: "+Execute(multiply,3,4)); | |
| } | |
| Func<int,int,int> add = (a,b) => a+b; | |
| Func<int,int,int> subtract = (a,b) => a-b; | |
| Func<int,int,int> multiply = (a,b) => a*b; | |
| public int Execute(Func<int,int,int> del,int a,int b) | |
| { | |
| return del(a,b); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C# implementation of Scala killer code
http://alvinalexander.com/scala/how-scala-killed-oop-strategy-design-pattern