using System.Collections;
using System.Collections.Generic;
public static void Main()
var w1 = FromInMemoryCollection();
private static IEnumerable<int> FromInMemoryCollection()
return new[]{0, 1, 2, 3};
private static IEnumerable<int> FromYielding()
private static IEnumerable<int> FromLinqing()
return FromYielding().Where(n => n % 2 == 0);
private static IEnumerable<int> FromCustom()
return new CustomEnumerable();
private class CustomEnumerable : IEnumerable<int>
private readonly IEnumerable<int> inner;
public CustomEnumerable()
inner = new [] { 0, 1, 2, 3 };
public IEnumerator<int> GetEnumerator()
return inner.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
return this.GetEnumerator();