Filter list contents with predicate (anonymous method)

49

Filter list contents with predicate (anonymous method) -

using System;
using System.Collections.Generic;

var data = new List<int> { 1, -2, 3, 0, 2, -1 };

Predicate<int> isPositive = delegate(int val) { return val > 0; };
var filtered = data.FindAll(isPositive);

Console.WriteLine(string.Join(",", filtered));

Comments

Submit
0 Comments