string[] listOne = new string[] { "dog", "cat", "car", "apple"};
string[] listTwo = new string[] { "car", "apple"};
我需要的是按
listOne
中的项目顺序(如果有)来订购listTwo
。因此,新列表将按以下顺序排列:“汽车”,“苹果”,“狗”,“猫”
最佳答案
您可以使用扩展方法Union()
var result = listTwo.Union<string>(listOne);
关于c# - Linq在字符串数组上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16765987/