linq - How to find where the records exists in the array or not using c# -
i having array of elements , records. want display records contains records in array.
for eg:
array contains: [1,2,3]
records contains: [1,2,3,4,5,6,7,8,9,10]
i want display 1,2,3
records. how compare in c#
sorry english.
assuming using linq query:
int[] array = new[] { 1,2,3 }; var record1 = new[] { 1,2,3,4,5,6,7,8,9,10 }; var record2 = new[] { 4,5,6,7,8,9,10 }; var records = new[] { record1, record2 }; // return record if @ least 1 record in array matched var result1 = r in records array.any(a => r.contains(a)) select r; // return record if items in array matched var result2 = r in records array.all(a => r.contains(a)) select r;
Comments
Post a Comment