using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
public class Foo
{
public string data { get; set; }
}
public class Bar : Foo
{
}
static void Main(string[] args)
{
var bars = new List<Bar>();
bars.Add(new Bar() { data = "hello" });
bars.Add(new Bar() { data = "world" });
var resultsA = GetFoos(bars, (b => b.data.StartsWith("h")));
var resultsB = GetBars(bars, (b => b.data.StartsWith("h")));
}
static List<Foo> GetFoos(IEnumerable<Foo> fooList, Func<Foo, bool> criteria)
{
return fooList.Where(criteria).ToList();
}
static List<Bar> GetBars(IEnumerable<Bar> barList, Func<Bar, bool> criteria)
{
return barList.Where(criteria).ToList();
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWM7CgpjbGFzcyBQcm9ncmFtCnsKICAgIHB1YmxpYyBjbGFzcyBGb28KICAgIHsKICAgICAgICBwdWJsaWMgc3RyaW5nIGRhdGEgeyBnZXQ7IHNldDsgfQogICAgfQoKICAgIHB1YmxpYyBjbGFzcyBCYXIgOiBGb28KICAgIHsKICAgIH0KCiAgICBzdGF0aWMgdm9pZCBNYWluKHN0cmluZ1tdIGFyZ3MpCiAgICB7CiAgICAgICAgdmFyIGJhcnMgPSBuZXcgTGlzdDxCYXI+KCk7CgogICAgICAgIGJhcnMuQWRkKG5ldyBCYXIoKSB7IGRhdGEgPSAiaGVsbG8iIH0pOwogICAgICAgIGJhcnMuQWRkKG5ldyBCYXIoKSB7IGRhdGEgPSAid29ybGQiIH0pOwoKICAgICAgICB2YXIgcmVzdWx0c0EgPSBHZXRGb29zKGJhcnMsIChiID0+IGIuZGF0YS5TdGFydHNXaXRoKCJoIikpKTsKICAgICAgICB2YXIgcmVzdWx0c0IgPSBHZXRCYXJzKGJhcnMsIChiID0+IGIuZGF0YS5TdGFydHNXaXRoKCJoIikpKTsKICAgIH0KCiAgICBzdGF0aWMgTGlzdDxGb28+IEdldEZvb3MoSUVudW1lcmFibGU8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