int range = 20;
var test = Enumerable.Range(0, range).Select(i => new Section { Id = i, Value = i }).ToList();
var result = RemoveEvenNum(test);
foreach (var section in result)
{
Console.WriteLine(section.Value);
}
And TestFunc is as below:
public static IEnumerable<Section> RemoveEvenNum(IEnumerable<Section> test)
{
foreach (var f in test)
{
var f1 = test.Where(t => t.Value % 2 == 0);
test = test.Except(f1);
}
return test;
}
If I set range as 20 or less, the codes executes well; However, if I increases range to 35 or more, I find that the codes executes much longer as the value of “range” increase? Can anyone give some hint on this? Thanks.
I’m expecting no much difference in performance if I set range as 20 or 30 or 40.
12