3 回答

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊
GetBoolValue() ? 10 : null
10
int
int?
null
null
int?
null
int
int?
(#2, #3).
GetBoolValue() ? (int?)10 : null // #1 GetBoolValue() ? 10 : (int?)null // #2 GetBoolValue() ? 10 : default(int?) // #3

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊
int? x = GetBoolValue() ? 10 : (int?)null;
10
int
int
int
null
null
Nullable<int>
Nullable<int>
10
int?

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超4個(gè)贊
int? result = condition ? 10 : default(int?);
- 3 回答
- 0 關(guān)注
- 351 瀏覽
添加回答
舉報(bào)