I have created some nested classes but don't unterstand how to set the variables in the classes. My code so far only gives me a error:
System.NullReferenceException: Object reference not set to an instance of an object
Code:
class Felddaten
{
public string data;
}
class Feld
{
public string fieldName;
public Felddaten[] fieldData;
}
class Tabelle
{
public string tableName;
public Feld[] field;
}
class Program
{
static void Main(string[] args)
{
Tabelle table = new Tabelle();
table.tableName = "T100";
RFCConnector connector = new RFCConnector();
connector.getFieldNames(table.tableName, out List<string> fieldN);
table.field = new Feld[fieldN.Capacity];
for (int i = 0; i < fieldN.Capacity; i++)
{
table.field[0].fieldName = fieldN[0];
}
}
}
The error is at this line of code:
table.field[0].fieldName = fieldN[0];