As the error describes, the error occurred because the Header property was not initialized and was null. You need to initialize your headerField instance before assigning subproperties.
private DT_FLEQHeader headerField = new DT_FLEQHeader();
One way to do it would be to initialize it when declaring the variable as above. But please be aware you could do it any other place as well before the first usage. For example, within the Constructor.
public DT_FLEQ
{
headerField = new DT_FLEQHeader();
}
Or within the Setter Accessor of Header property
public DT_FLEQHeader Header
{
get
{
return this.headerField;
}
set
{
if(this.headerField == null)
{
headerField = new DT_FLEQHeader();
}
this.headerField = value;
}
}
You could also initialize it just prior to assigning the FLTYP value. For example,
FLEquipment.Header = new DT_FLEQHeader();
FLEquipment.Header.FLTYP= "Value";
The important point is, the variable headerField needs to be initialized before being assigned the value.
The alternative is creating an instance of DT_FLEQHeader and assign it to FLEquipment.Header.
var header = new DT_FLEQHeader();
header.FLTYP= "Value";
FLEquipment.Header = header;