My class looks like this.
public class LogSettings
{
public string attributeName { get; set; }//TODO: change the variable name
public Warnings[] warnings = new Warnings[3];
}
public class Warnings
{
public string typeOfWarning {get; set;}
public bool isAbsolute { get; set; }
public decimal numUpDownValue { get; set; }
public LogSettingActions[] actionItems = new LogSettingActions[10];
}
public class LogSettingActions
{
public string actionItem{ get; set;}
}
but when I try to create Warnings instance it throws NullReference error.
var rows = FindChilds<ctlLogConfigRow>(lvLogConfigTemplate);
foreach (var row in rows)
{
LogSettings instance = new LogSettings();
instance.attributeName = row.GroupHeaderText;
var allWarnings = FindChilds<ctlWarnings>(row);
for (int i = 0; i < allWarnings.Count; i++)
{
instance.warnings[i].typeOfWarning = allWarnings[i].ctlWarningGroupBoxFixedHeader1.Header.ToString();//It throws error here
Can anybody help me?
LogSettings.warningsis initialized as an array, but the array elements are not initialized.Consider initialing the array items in the LogSettings constructor: