.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.

eric lippert's cast operators not obey distributive law


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -