I have the following section of code that acts on values in <Test></Test>
nodes from an xml file:
var tests = new ServicesTests();
var testcase = new TestData();
var x = 0;
foreach (XPathNavigator test in Service.Select("Testname"))
{
testcase.Testname[x] = test.Value;
x++;
}
tests.ServiceTests.Add(testcase);
The objects were declared here:
public class ServicesTests
{
public List<TestData> ServiceTests = new List<TestData>();
}
public class TestData
{
...
public string[] Testname { get; set; }
}
Now I receive a null value reference exception when trying to set the array. I understand why, but I'm not sure what the proper way to initialize it is, since I will have no way of knowing just how many values there can be. All the examples I've read seem to assume knowing this..
Any suggestions on how this should be done properly?
Thanks
EDIT: I updated to add some code previously missing since using a list still returns a null reference error.