I have built a simple code as shown below. While debugging, I am getting an error about "NullReference Handled Exception" at the code line:
X.DataPoints.Add(dp);
Here is the code snippet. Please advice on what am I missing?
public class RankPlot
{
public List<RankPlotDataPoint> DataPoints { get; set; }
}
public class RankPlotDataPoint
{
public double RankVal { get; set; }
public double ProbVal { get; set; }
}
ObservableCollection<RankPlot> EURresults = new ObservableCollection<RankPlot>();
public ObservableCollection<RankPlot> EURResults
{
get { return EURresults; }
set
{
EURresults = value;
base.OnPropertyChanged("StringList");
}
}
public void evaluate()
{
RankPlot X = new RankPlot();
for (double i = 0; i<5; i++)
{
RankPlotDataPoint dp = new RankPlotDataPoint();
dp.RankVal =i+1; // Y axis
dp.ProbVal = i; // X axis
X.DataPoints.Add(dp);
}
EURResults.Add(X);
}