I want to use Linq to compare the values of two Lists based on a different field in each list where the list item values are a string[] array.
The format of the arrays are as follows :
Array 1
- List
- 4 fields per
string[]entry
Array 2
- List
- 15 fields per
string[]entry
I am trying to compare the value of field 0 from array 1, to check if that value exists in any record in field 12 in array 2, and return the array 1 records where there was no match found in array 2.
What I have so far, is :
var r = array1.Where( p => array2.All( p2 => p2[12] != p[0] ) ).ToList(); This is giving me the following error :
An unhandled exception of type 'System.IndexOutOfRangeException'
How can I make this work ? I know I could do a nested loop O(n)^n, however this is not ideal, which is why I wish to use Linq to compare the sub-values.
Anyinstead ofAllarray1andarray2. dont explain just code please!O(n^m).AllandWhereare O(n) too so they will perform same