0

它们似乎不适用于 C#

string[] directions = 
      IsSomeValueTrue ? string[]{"RIGHT", "LEFT"} : string[]{"UP", "DOWN"};

string[] directions = 
      IsSomeValueTrue ? new string[]{"RIGHT", "LEFT"} : new string[]{"UP", "DOWN"};

我错过了什么?

4

2 回答 2

3

最短的单线:

var dirs = IsSomeValueTrue ? new[] {"RIGHT", "LEFT"} : new[] {"UP", "DOWN"};
于 2013-10-24T23:27:35.513 回答
0

尝试这个:

string[] directions = IsSomeValueTrue ? new string[] {"RIGHT", "LEFT"} : new string[]{"UP", "DOWN"};
于 2013-10-24T23:25:33.783 回答