Because the two return values of the ternary are not of the same type -- one is int and the other is string. The compiler cannot deduce what the ternary expression's return type is.
Solution: Return the same type from both branches, or cast one of them to a base of the other. object will do fine.