【发布时间】:2011-06-25 06:08:59
【问题描述】:
这是我想做的:
string x = if(true) "String Val" else "No String Val";
这可能吗?
【问题讨论】:
-
可能不是这个问题的有效答案(因此改为评论):如果您的条件是空检查,例如
string x = (s != null) ? s : "Something else",你可以做string x = s ?? "Something else"
标签: c# methods conditional inline-method