I have one class with 2 lists as it's data member. I want to include these data members as a different class' objects.
I am getting this error:
"Object reference not set to an instance of an object."
Kindly advise what should be the proper approach.
class dataPoints
{
public List<double> dataValues;
public List<DateTime> timeStamps;
public dataPoints()
{
this.timeStamps = new List<DateTime>();
this.dataValues = new List<double>();
}
}
//I want an object of dataPoints in this below classs
class wellGraph
{
int seriesAdded;
dataPoints[] graphDataPoints;
public wellGraph(int Entries)
{
this.seriesAdded = 0;
this.graphDataPoints = new dataPoints[Entries];
for(int i=0;i<Entries;i++)
{
graphDataPoints[i].timeStamps = new List<DateTime>();
graphDataPoints[i].dataValues = new List<double>();
}
}
}
With the constructor removed in dataPoints class, the same error persists.