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