我有一个主要的颜色列表:
List<string> completeList = new List<string>{"red", "blue", "green", "purple"};
Run Code Online (Sandbox Code Playgroud)
我正在传递产品现有颜色的列表
List<string> actualColors = new List<string>{"blue", "red", "green"};
Run Code Online (Sandbox Code Playgroud)
如何获得完整列表顺序的列表?(红,蓝,绿)
Dan*_*ite 16
var ordered = completeList.Intersect(actualColors);
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,请执行此操作
var ordered = actualColors.Intersect(completeList);
Run Code Online (Sandbox Code Playgroud)