I have a list of strings on the format yyyy.mm.ddThh, I'd like to create a tree like structure of its components(Years, Months,Days,Hours)
e.g. I have a list like:
List<String> l = new List<String>()
l.add("2010.10.11T10");
l.add("2010.10.11T11");
l.add("2010.09.01T23");
l.add("2009.01.02T03");
From this I'd like something like:
new {
{ Year = 2009,
Months = { { Month = 01, Days = { {Day = 02, Hours = {{Hour = 03}}}}},
{ Year = 2010
Months = { { Month = 10, Days = { {Day = 11, Hours = {{Hour = 10,Hour = 11}}}}},
{ Month = 09, Days = { {Day = 01, Hours = {{ Hour = 23}}}}}
}
}
Surely that should be possible with linq ?