I wanna do something like this:
List<string> list = new List<string>();
... put some data in it ...
list.CallActionForEachMatch(x=>x.StartsWith("a"), ()=> Console.WriteLine(x + " matches!"););
Syntax: CallActionForEachMatch(Criteria, Action)
How is this possible? :)
I wouldn't; I'd just use:
foreach(var item in list.Where(x=>x.StartsWith("a"))) {
Console.WriteLine(item + " matches!");
}
But you could use:
list.FindAll(x=>x.StartsWith("a"))
.ForEach(item=>Console.WriteLine(item + " matches!"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With