【发布时间】:2017-09-13 19:38:27
【问题描述】:
我正在尝试找到一种更简单的方法将此三元表达式转换为 if else 表达式。
Account account = selection != 1 ? (Account)customer.Saving : (Account)customer.Checking;
【问题讨论】:
-
Account account; if (selection != 1) { account = (Account)customer.Saving } else { account = (Account)customer.Checking; }...但是为什么呢? -
你确定你是这个编码的人吗?
-
只是对等价的表达感到好奇。
标签: c# ternary-operator