C#,C#の宿題片付けます。
■ このスレッドは過去ログ倉庫に格納されています
0314デフォルトの名無しさん
2009/02/06(金) 00:46:17ほんとうに・・・?
// LINQつかってまう
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
var listDay = eachDay(new DateTime(2009, 1, 1), new DateTime(2009, 1, 5)).ToList();
listDay.ForEach(x => Console.WriteLine(x.ToShortDateString()));
Console.WriteLine(listDay.Count);
Console.Read();
}
private static IEnumerable<DateTime> eachDay(DateTime begin, DateTime end) {
for (DateTime tmp = begin; tmp <= end; tmp = tmp.AddDays(1)) {
yield return tmp;
}
yield break;
}
}
}
■ このスレッドは過去ログ倉庫に格納されています