Click here to Skip to main content
15,848,904 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
What is the most efficient way to take every element in a list and do some operation on it. For example say you have a list of objects that all have x,y data points. You have a function that can calculate the dot product but I want to calculate the dot product against every other element
Posted

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

—SA
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900