有人能解釋一下我下面的編譯器問題C#? :運營商
Error: Type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'int'
// WORKS
string text = string.Format(
"the id is {0}", _Obj.Id.ToString());
// WORKS, without implicit conversion <<<
string text = string.Format(
"the id is {0}", _Obj.Id);
// WORKS
string text = string.Format(
"the id is {0}", (_Obj == null) ? "unknown" : _Obj.Id.ToString());
// NO WAY <<<
string text = string.Format(
"the id is {0}", (_Obj == null) ? "unknown" : _Obj.Id);
在最後一個例子,不存在隱式轉換,以及。
沒有................:0對不起。看到我的回答如下... – UpTheCreek 2010-11-15 11:43:09