Question: One more question from the [series](https://stackoverflow.com/questions/21403467/is-void-a-valid-return-value-for-a-function) "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?

Answer: 
Overloading is resolved at compile time, not at run time. The ternary operator `?:` is evaluated at runtime. So at compile time, compiler doesn't know which function overload to link to as it doesn't know if `id==0` or not. That's why your second example works because which overload called there can be resolved at compile time.

The reason for overloading is convenience of calling the same logical function with different number or type of parameters.
You did not post the error you got, but by the look of it the failure has nothing to do with overloading.

The error is because the ternary operator `?` cannot get a string and int arguments, they need to be of the same type or with an implicit cast between them.

[this](https://stackoverflow.com/questions/18260528/type-of-conditional-expression-cannot-be-determined-because-there-is-no-implicit) post explains it rather well.

**Edit:**  

From the spec, you can understand the reason for the failure:

> 
> If x has type X and y has type Y then:
> 
> 
> * If an implicit conversion (§6.1) exists from X to Y, but not from Y to X, then Y is the type of the conditional expression.
> * If an implicit conversion (§6.1) exists from Y to X, but not from X to Y, then X is the type of the conditional expression.
> * Otherwise, no expression type can be determined, and a compile-time error occurs.
> 
> 
>