【发布时间】:2011-05-13 19:59:39
【问题描述】:
可能的重复:
Why can't I set a nullable int to null in a ternary if statement?
Nullable types and the ternary operator. Why won't this work?
下面有什么问题
public double? Progress { get; set; }
Progress = null; // works
Progress = 1; // works
Progress = (1 == 2) ? 0.0 : null; // fails
无法确定条件表达式的类型,因为'double'和'
'之间没有隐式转换
【问题讨论】:
标签: c#