Skip to content

Instantly share code, notes, and snippets.

@oguzhaneren
Created October 8, 2015 15:39
Show Gist options
  • Save oguzhaneren/bdbc83aba5bb1accd79d to your computer and use it in GitHub Desktop.
Save oguzhaneren/bdbc83aba5bb1accd79d to your computer and use it in GitHub Desktop.
How C# killed the Strategy Pattern
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);
}
@oguzhaneren
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment