What is the easiest way to convert List<DayValue> to array, where index is day of month:
class DayValue
{
public DateTime Day { get; set; }
public object Value { get; set; }
}
I need to do this inline, because this will be used in linq. I know I can just iterate throug items and set array values, but this needs to be done line that
list.FunctionThatConvertsItIntoArray()
Example:
Input list:
{ 2012-11-01, "Value1" }
{ 2012-11-03, "Value2" }
{ 2012-11-05, "Value3" }
Output array:
1 => "Value1"
2 => null
3 => "Value2"
4 => null
5 => "Value3"
6 => null
7 => null
8 => null
9 => null
10 => null
11 => null
12 => null
13 => null
14 => null
15 => null
16 => null
17 => null
18 => null
19 => null
20 => null
21 => null
22 => null
23 => null
24 => null
25 => null
26 => null
27 => null
28 => null
29 => null
30 => null
1 Answer