Csharp/C Sharp/LINQ/Reverse — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:38, 26 мая 2010
An Example Calling the Reverse Operator
<source lang="csharp"> using System; using System.Linq; using System.Collections; using System.Collections.Generic; public class MainClass {
public static void Main() { string[] presidents = {"lore", "Truman", "Tailer", "Van", "Washington", "Wilson"}; IEnumerable<string> items = presidents.Reverse(); foreach (string item in items) Console.WriteLine(item); }
}
</source>
Reverse does exactly as it says
<source lang="csharp"> using System; using System.Collections.Generic; using System.Linq; public class MainClass {
public static void Main() { int[] numbers = { 10, 9, 8, 7, 6 }; IEnumerable<int> reversed = numbers.Reverse(); // { 6, 7, 8, 9, 10 } }
}
</source>