- Using C# delegates with methods with optional parameters
- delegate int Del(int x);
- static int Foo(int a, int b = 123)
- {
- return a+b;
- }
- static void Main()
- {
- Del d = Foo;
- }
- delegate int Del(int x, int y = 123);
- delegate int Del(int x, int y = 456);
- static int Foo(int a, int b = 123)
- {
- return a+b;
- }
- static void Main()
- {
- Del d = Foo;
- Console.WriteLine(d(1));
- }