接线员? :惊讶,惊讶

时间:2015-03-31 08:36:21

标签: c# syntax-error

想象一下情况

int? customerId = null; // works fine
int? customerId = 5; // also fine
int? customerId = someCondition ? 5 : null; // There is no implicit conversion between int and null
int? customerId = someCondition ? 5 : (int?)null; // now is ok

这怎么可能?这是语言规范吗?对我来说,显而易见的是隐式转换。你觉得怎么样?

0 个答案:

没有答案