using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace IEnumなんとかてすと { class Program { static void Main(string[] args) { int[] A = new int[16] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; foreach (var o in A.SkipEnd()) { Console.Write("{0} ", o); } return; } } public static class ExtFunc { public static IEnumerable SkipEnd(this IEnumerable Enumerable) { var En = Enumerable.GetEnumerator(); int N = Enumerable.Count(); int i = 0; while (En.MoveNext()) { i++; if (N == i) break; yield return En.Current; } } } }