One more question from the series "why does VisualStudio not support this code?"...
Given an overloaded function
private string ConfigQuery(string username) {
return "A";
}
private string ConfigQuery(int configId) {
return "B";
}
the following code is not possible:
public Config ConfigAPI(int id=0) {
string s = ConfigQuery(id==0?User.Identity.Name:id);
}
but the code
public Config ConfigAPI(int id=0) {
string s = (id==0?ConfigQuery(User.Identity.Name):ConfigQuery(id));
}
is. Is this reasonable behaviour? Then why would I use an overloaded function at all, instead of giving them more appropriate names like UserNameConfigQuery, ConfigIdConfigQuery?