I have multiple overloaded methods. But I cannot call the right one. How to tell the compiler that I want especially "THIS METHOD" to be called "WITH THIS PARAMETERS"?
The naughty method is the second one:
public string Translate(string text, params object[] args)
{
// Blah blah blah...
}
public string Translate(string text, string category, params object[] args)
{
// Here we do some blah blah blah again...
}
Here when I try to call the first method like this: Translate("Hello {0} {1}", "Foo", "Bar");
the compiler assumes that I'm calling the second method and sets the arguments as category = "Foo"
and args = "Bar"
.
I tried to name the parameters while calling them but it gave me some compiler errors.
Translate("Hello {0} {1}", args: "Foo", "Bar"); // CS1738
Translate("Hello {0} {1}", args: "Foo", args: "Bar"); // CS1740
How can I achieve this?