|
using System;
using System.Linq;
普通にDateでgroupbyした結果を、ゆっくり料理すればいいような気がします。
namespace ConsoleApplication3
{
class Record
{
public string Date { get; set; }
public int Number { get; set; }
public int Value { get; set; }
}
class Program
{
static void Main(string[] args)
{
var data = new[]
{
new Record { Date = "1/1", Number = 1, Value = 234 },
new Record { Date = "1/1", Number = 2, Value = 12 },
new Record { Date = "1/1", Number = 3, Value = 455 },
new Record { Date = "1/2", Number = 1, Value = 235 },
new Record { Date = "1/2", Number = 2, Value = 13 },
new Record { Date = "1/2", Number = 3, Value = 453 },
new Record { Date = "1/3", Number = 1, Value = 229 },
new Record { Date = "1/3", Number = 2, Value = 15 },
new Record { Date = "1/3", Number = 3, Value = 444 },
};
var results = from record in data
orderby record.Number
group record by record.Date;
foreach (var result in results)
{
Console.WriteLine(result.Key);
foreach (var g in result)
{
Console.WriteLine("\t{0}, {1}", g.Number, g.Value);
}
}
}
}
}
|