Created
December 21, 2015 14:20
-
-
Save BojanKomazec/a1c200db3676675e5d28 to your computer and use it in GitHub Desktop.
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
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var c = new C(); | |
c.FooCall(123); | |
c.FooCall(456); | |
} | |
} | |
public class C | |
{ | |
private delegate void BarFixedInt(string s); | |
public void FooCall(int i) | |
{ | |
this.Foo((s) => this.Bar(i, s)); | |
} | |
private void Foo(BarFixedInt barFixedInt) | |
{ | |
var s = "test1"; | |
barFixedInt.Invoke(s); | |
// do something... | |
s = "test2"; | |
barFixedInt.Invoke(s); | |
// do something | |
s = "test3"; | |
barFixedInt.Invoke(s); | |
// etc... | |
} | |
private void Bar(int i, string s) | |
{ | |
Console.WriteLine($"i = {i}, s = {s}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment