我想按属性值将我的数据拆分为列表,并检查列表项目之间的所有组合选项。我的问题是我不知道我会得到多少列表,以及除此之外是否有更好的方法:
var a = Data.Descendants("value").Where(x => x.Attribute("v").Value == "1").ToList(); var b = Data.Descendants("value").Where(x => x.Attribute("v").Value == "2").ToList(); var c = Data.Descendants("value").Where(x => x.Attribute("v").Value == "3").ToList();
foreach(a 中的 var tempA){ foreach(b 中的 var tempB){ foreach(c 中的 var tempC){ 做某事;} } }
编辑:我想从一个数据源检查我的项目 ( var items = new List<string>{"1","1","2","3","2","1","3","3","2"}
)
现在我想将此列表拆分为 3 个列表 ( list a = "1","1","1" - list b = "2","2","2" - list c = "3","3","3"
)
在这一步中,我要做的是检查从一个列表中的一个项目到其他列表中的其他项目的所有组合。
a[0] with b[0] c[0]
a[0] with b[0] c[1]
a[0] with b[0] c[2]
a[0] with b[1] c[0]
.
.
b[1] with a[2] c[2]
.
.
谢谢!