private static IEnumerable <SubSomething> YieldReturnLoopCore(IEnumerable <Something> source) { foreach (Something val in source) { SubSomething subVal = val as SubSomething; if (subVal != null) { yield return(subVal); } } }
private static IEnumerable <Something> GenerateTestInput() { List <Something> data = new List <Something>(); foreach (int i in Enumerable.Range(0, 1000000)) { Something item = new Something(); if (i % 2 == 0) { item = new SubSomething(); } data.Add(item); } return(data); }