c# 4.0 - How is the long method way of doing below code in "Lambda Expressions" in the past? -
public static ienumerable<t> get<t>(this ienumerable<t> source, func<t, bool> predicate) { foreach (t item in source) { if (predicate(item)) yield return item; } }
like this:
public static ienumerable<t> get<t> (ienumerable<t> source, func<t, bool> predicate) { var list = new list<t>(); foreach (t item in source) { if (predicate(item)) { list.add(item); } } return list; }
Comments
Post a Comment