So does anyone know a way to force the use of the method with the default parameter?
I thought of a solution with a special delegate for this case - But this doesn't work like I first thought: look how this behaves...
class Program
{
delegate void methodDelegate(string str = "ABC");
static void Main()
{
method();
methodDelegate methodWithOptionalParameter = method;
methodWithOptionalParameter.Invoke();
Console.ReadKey();
}
static void method(string str = "XYZ")
{
Console.WriteLine("method(string str = \"{0}\")", str);
}
static void method()
{
Console.WriteLine("method()");
}
}
(hint: it uses the default value from the delegate Definition)