I have a static class:
public static class Options
{
public static MiscSettings MiscSettings;
public static Units Units;
}
My definitions for the two property classes looks like this:
[Serializable]
public class Units
{
public LengthUnit LengthUnit { get; set; } = LengthUnit.Millimeter;
public VolumeUnit VolumeUnit { get; set; } = VolumeUnit.CubicCentimeter;
}
[Serializable]
public class MiscSettings
{
public bool OutputDebugging { get; set; } = false;
}
When I do:
Options.Units = OptionsData.Units;
Options.MiscSettings.OutputDebugging = false;
The first line executes ok. The second gives me a NullReference Exception. The property Options.MiscSettings is null. The next error is Object not set to an instance of an object.
I've tried renaming everything, changing order of the properties. I also tried moving the property OutputDebugging to the Units class and that worked just fine.
Any help would be appreciated.