我想知道从其他数组的内容创建新数组的最有效方法。
我有几种类型的字符串数组:
public readonly string[] Taiwan = { "TW", "TWO" };
public readonly string[] Vietnam = { "HM", "HN", "HNO" };
public readonly string[] Korea = { "KQ", "KS" };
public readonly string[] China = { "SS", "SZ" };
public readonly string[] Japan = { "T", "OS", "NG", "FU", "SP", "Q", "OJ", "JNX", "IXJ", "KAB", "JA", "JPx" };
现在可以用与此类似的方式创建一个新的字符串数组吗?
public readonly string[] ASIA = { Taiwan, Vietnam, Korea, China, Japan};
那将包含其他数组中包含的所有字符串。
最佳答案
string[] ASIA = new []{ Taiwan, Vietnam, Korea, China, Japan}
.SelectMany(s => s) // not entirely sure what these abbreviations are...
.ToArray();
关于c# - 使用C#中其他数组的内容创建新数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17753670/