yohei #3846(2007/11/11 11:54 GMT) [ C# ] Rating0/0=0.00
無限にyield。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
using System; using System.Collections.Generic; class Program { static IEnumerable<string> FizzBuzz() { while (true) { yield return "hoge"; yield return "hoge"; yield return "Fizz"; yield return "hoge"; yield return "Buzz"; yield return "Fizz"; yield return "hoge"; yield return "hoge"; yield return "Fizz"; yield return "Buzz"; yield return "hoge"; yield return "Fizz"; yield return "hoge"; yield return "hoge"; yield return "FizzBuzz"; } } static void Main(string[] args) { int i = 0; foreach (string s in FizzBuzz()) { if (++i > 20) break; Console.WriteLine("{0, 2}:{1}", i, s); } } }
Rating0/0=0.00-0+
[ reply ]
yohei
#3846()
[
C#
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]