# 可能通过foreach向后迭代？

` `IEnumerable<int> enumerableThing = ...; foreach (var x in enumerableThing.Reverse())` `

` `static IEnumerable<T> Reverse<T>(IEnumerable<T> input) { return new Stack<T>(input); }` `

` `public static IEnumerable<T> FastReverse<T>(this IList<T> items) { for (int i = items.Count-1; i >= 0; i--) { yield return items[i]; } }` `

` `public static IEnumerable<T> GetStringsOfIncreasingSize() { string ret = ""; while (true) { yield return ret; ret = ret + "x"; } }` `

` `List<string> list = new List<string>(); list.Add("1"); list.Add("2"); list.Add("3"); list.Reverse();` `

` `foreach(string s in list) { Console.WriteLine(s); }` `

` `3 2 1` `

` ` myList.Reverse(); foreach( List thisList in myList) { Console.WriteLine(thisList); }` `

` `public IEnumerator<TObject> GetEnumerator() { for (var i = items.Count - 1; i >= 0; i--) { yield return items[i]; } } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }` `

` ` public static IEnumerable<T> Invert<T>(this IEnumerable<T> source) { var transform = source.Select( (o, i) => new { Index = i, Object = o }); return transform.OrderByDescending(o => o.Index) .Select(o => o.Object); }` `

` ` var eable = new[]{ "a", "b", "c" }; foreach(var o in eable.Invert()) { Console.WriteLine(o); } // "c", "b", "a"` `

` ` public static IEnumerable<T> Invert<T>(this IEnumerable<T> source, int index, int count) { var transform = source.Select( (o, i) => new { Index = i < index ? Int32.MaxValue : i >= index + count ? Int32.MinValue : i, Object = o }); return transform.OrderByDescending(o => o.Index) .Select(o => o.Object); }` `

` ` var eable = new[]{ "a", "b", "c", "d" }; foreach(var o in eable.Invert(1, 2)) { Console.WriteLine(o); } // "a", "c", "b", "d"` `

` ` if (element.HasAttributes) { foreach(var attr in element.Attributes().Reverse()) { if (depth > 1) { elements_upper_hierarchy_text = ""; foreach (var ancest in element.Ancestors().Reverse()) { elements_upper_hierarchy_text += ancest.Name + "_"; }// foreach(var ancest in element.Ancestors()) }//if (depth > 1) xml_taglist_report += " " + depth + " " + elements_upper_hierarchy_text+ element.Name + "_" + attr.Name +"(" + attr.Name +")" + " = " + attr.Value + "\r\n"; }// foreach(var attr in element.Attributes().Reverse()) }// if (element.HasAttributes) {` `

` `List<string> list = new List<string>(); list.Add("Hello"); list.Add("Who"); list.Add("Are"); list.Add("You"); foreach (String s in list) { Console.WriteLine(list[list.Count - list.IndexOf(s) - 1]); }` `
• 什么是标记结构初始化语法？
• 为什么WCF中不允许重载方法？
• 如何写一个“等待”的方法？
• 哪个std :: async实现使用线程池？
• 在Visual Studio中预处理后，如何查看C / C ++源文件？
• dup2 / dup – 为什么我需要复制文件描述符？
• 我如何确定我的数组在C中的大小？
• 我如何测量C中的时间间隔？
• gdb – 用pipe道debugging
• 如何制作一个简单的C ++ Makefile？
• 为什么C ++需要用户提供的默认构造函数来默认构build一个const对象？