Csharp/CSharp Tutorial/LINQ/Enumerable.Repeat — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:18, 26 мая 2010
Returning a Sequence of Ten Integers All With the Value Two
<source lang="csharp">using System; using System.Linq; using System.Collections; using System.Collections.Generic; public class MainClass {
public static void Main() { IEnumerable<int> ints = Enumerable.Repeat(2, 10); foreach (int i in ints) Console.WriteLine(i); }
}</source>
Using Repeat to generate a sequence that contains the number 7 ten times.
<source lang="csharp">using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass {
public static void Main() { var numbers = Enumerable.Repeat(7, 10); foreach (var n in numbers) { Console.WriteLine(n); } }
}</source>