I have an application that has multiple dynamic custom user controls to gather edge names and curve offsets in datagridviews. My goal is to enter them into a class with some methods to retrieve some common groups of data to process later.
I have one class that defines the format for the offsets (as it will be the same for both single edges, and a list of edges), and then another class that groups those edges into one "Example". The methods in the second class will return common arrays I need for each Example.
The code is below- complies ok- then when I try to set the sName property of the offSet it returns a NullReferenceException
. I suspect I am not initializing things correctly inside of the Example class, or not exposing or declaring them correctly (static, abstract, virtual??). The offSets class works fine, but not when it's accessed within the Example class.
Please help!
private class offSets
{
public string sName { get; set; }
public double d0 { get; set; }
public double d1 { get; set; }
public double d2 { get; set; }
public double d3 { get; set; }
public double d4 { get; set; }
public double d5 { get; set; }
public double d6 { get; set; }
public double d7 { get; set; }
public double d8 { get; set; }
public double dLength { get; set; }
}
private class Example
{
public offSets curve1 { get; set; }
public offSets curve2 { get; set; }
public List<offSets> lstCurves { get; set; }
public string testString { get; set; }
public double[] somemethod()
{
//code that returns an array - something lie:
return this.lstCurves.Select(i => i.d2).ToArray();
}
}
private void temp()
{
Example e = new Example();
e.testString = "This is some test text";
MessageBox.Show(e.testString);
// This works as expected.
e.curve1.sName = "Some Name";
// error on above line: "System.NullReferenceException"
}