I am using a data collection for a data series of a chart. The data collection has a “day” member for the charts X axis, and “value” member for the charts Y axis.
When I add the items to the data collection like following it is not working.The data collection remains empty and I get System.NullReferenceException when I try to reach the elements of it.
(Method FillData is called initialy in my app.)
Is there a basic failure in my approach?
class DataItem
{
public int Day { get; set; }
public double Value { get; set; }
}
public void FillData()
{
List<DataItem> value2024 = new List<DataItem>();
for (int i=0; i<5;i++)
{
value2024.Append(new DataItem { Day = i+1, Value = i*10});
}
}