I'm using Microsoft Visual C# 2010, and I'm very new to this (although I've had lots of previous experience in other languages).
I may be going around this the complete wrong way, so any advice would be much appreciated.
I'm trying to design a watering system computer: It is made up of different systems
, each system comprised of 14 days
, and each day comprised of 10 cycles
, and each cycle has the properties hour
I thought the best way to go about working with all this data would be to define structures for a system, day and cycle. At the moment I have this:
public WaterDay WaterDays;
public WaterSystem(byte SystemIndex)
WaterDays = new WaterDay;
public WaterCycle WaterCycles;
public WaterDay(byte DayIndex = 0)
WaterCycles = new WaterCycle;
public byte hour;
public byte minute;
public byte duration;
public WaterCycle(byte Duration = 0)
hour = 0;
minute = 0;
duration = 0;
In my main class I then have:
public partial class MainWindow : Form
private WaterSystem WaterSystems = new WaterSystem;
In a particular method I then want to set some dummy data into a water cycle, and I have:
WaterSystems.WaterDays.WaterCycles.hour = 12;
WaterSystems.WaterDays.WaterCycles.minute = 37;
WaterSystems.WaterDays.WaterCycles.duration = 20;
But this is where I'm getting errors. I'm guessing I've probably gone wrong fundamentally somewhere, but the error I'm getting at this point is NullErrorException: Object reference not set to an instance of an object.
And help or pointers would be greatly appreciated.