.net - C# ? : operator -
could explain me following compiler issue
error: type of conditional expression cannot determined because there no implicit conversion between 'string' , 'int'
// works string text = string.format( "the id {0}", _obj.id.tostring()); // works, without implicit conversion <<< string text = string.format( "the id {0}", _obj.id); // works string text = string.format( "the id {0}", (_obj == null) ? "unknown" : _obj.id.tostring()); // no way <<< string text = string.format( "the id {0}", (_obj == null) ? "unknown" : _obj.id);
in last example, there no implicit conversion, well.
Comments
Post a Comment