I have the following partial classes:
public partial class FormInstance
{
private string referenceField;
public string Reference
{
get { return this.referenceField; }
set { this.referenceField = value; }
}
}
public partial class FormField
{
private string fieldNameField;
private string fieldValueField;
public string FieldName
{
get { return this.fieldNameField; }
set { this.fieldNameField = value; }
}
public string FieldValue
{
get { return this.fieldValueField; }
set { this.fieldValueField = value; }
}
}
public partial class EFormData
{
private FormInstance formInstanceField;
private FormField[] formDataField;
public FormInstance EFormInstance
{
get { return this.formInstanceField; }
set { this.formInstanceField = value; }
}
public FormField[] FormData
{
get { return this.eformDataField; }
set { this.eformDataField = value; }
}
}
I have a method as follows which has a parameter that is of the above class object type:
public int writeEformData(EformData formFields)
{
object[] results = this.Invoke("writeEformData", new object[] {
formFields});
return ((int)(results[0]));
}
In my code I'm trying to initialise the EformData object as follows:
EformData eformData = new EformData ();
eformData.EformInstance.Reference = "1234";
eformData.FormData[0].FieldName = "txt_name";
eformData.FormData[0].FieldValue = "John Doe";
eformData.FormData[1].FieldName = "txt_address";
eformData.FormData[1].FieldValue = "10 Acacia Ave";
int result = web.writeEformData(eformData);
but when I debug I get error on line 2 eformData.EformInstance.Reference = "1234";
An unhandled exception of type 'System.NullReferenceException' occurred
Additional information: Object reference not set to an instance of an object.
Whats the correct syntax to initialise the EformData object and assigning values as I'm trying to do above?