且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将列表中的每个元素与每个其他元素进行比较

更新时间:2023-02-05 13:45:02

嵌套循环。但是,你有什么期待奇迹?没有奇迹这样的东西。



-SA
Nested loop. But what, did you expect some miracle? There is no such thing as miracle.

—SA


string [] textlist = new string [] {a,b,c};

var intersecting = from text a in textlist

from string b in textlist

where((a!= b)&&(a.CompareTo(b)== -1))//&& a.SomeCondition(b)

选择新{object1 = a,object2 = b}

;



intersecting.Dump(结果);





Kishor Makwana

软件工程师

Insight Softech

www.insightsoftech.com
string[] textlist = new string[] {"a", "b", "c"};
var intersecting = from string a in textlist
from string b in textlist
where ((a != b) && (a.CompareTo(b) == -1)) // && a.SomeCondition(b)
select new { object1 = a, object2 = b }
;

intersecting.Dump("Result");


Kishor Makwana
Software Engineer
Insight Softech
www.insightsoftech.com