LINQ: How to Use RemoveAll without using For loop with Array
Posted
by CrimsonX
on Stack Overflow
See other posts from Stack Overflow
or by CrimsonX
Published on 2010-05-21T18:01:35Z
Indexed on
2010/05/21
18:20 UTC
Read the original article
Hit count: 318
I currently have a log object I'd like to remove objects from, based on a LINQ query. I would like to remove all records in the log if the sum of the versions within a program are greater than 60. Currently I'm pretty confident that this'll work, but it seems kludgy:
for (int index = 0; index < 4; index++)
{
Log.RemoveAll(log =>
(log.Program[index].Version[0].Value +
log.Program[index].Version[1].Value +
log.Program[index].Version[2].Value ) > 60);
}
The Program is an array of 4 values and version has an array of 3 values. Is there a more simple way to do this RemoveAll in LINQ without using the for loop?
Thanks for any help in advance!
© Stack Overflow or respective owner