它们似乎不适用于C#
string[] directions =
IsSomeValueTrue ? string[]{"RIGHT", "LEFT"} : string[]{"UP", "DOWN"};
string[] directions =
IsSomeValueTrue ? new string[]{"RIGHT", "LEFT"} : new string[]{"UP", "DOWN"};
我缺少什么?
答案 0 :(得分:3)
最短的单行:
var dirs = IsSomeValueTrue ? new[] {"RIGHT", "LEFT"} : new[] {"UP", "DOWN"};
答案 1 :(得分:0)
试试这个:
string[] directions = IsSomeValueTrue ? new string[] {"RIGHT", "LEFT"} : new string[]{"UP", "DOWN"};