list<string> arrs=new list<string>(){"1_2","1_3","2_3","2_4","3_9","3_11","4_1","4_12"};
dictionary<string,list<string> dics=new dictionary<string,list<string> ();
通过arrs集合里的每个元素下划线前的第一个数字进行分组
for(var s in arrs)
{
var key=s.Split(‘_‘)[0];
if(!dics.contains(s.Split(‘_‘)[0]))
{
dics.add(key,new list<string>);
}
dics.add(key,s)
}
list<string> termList=new list<string>();
int i=0;
for(var dic in dics)
{
i++;
if(i==1)
{
termlist=dic[0];
continue;
}
for(var i interm)
{
list<string> list=new list<string>();
for(var j in dic)
{
list.add(i+","+"j");
}
termlist=list;
}
}
时间: 2024-11-09 10:52:53