C# Properties - Need Sub Properties

c#, class, json, properties, xml

Solution

All you have to do is make WDay have properties for all the days:

public class WDay
{
    public Day Monday {get;set;}
    ...

Then have the `Day` class have a `TempHiF` property, and so on:

public class Day
{
    public string TempHif {get;set;}
    ...
}

Make sure WDay's constructor initializes all its Day properties with new instances to avoid null reference exceptions.

Problem

I have been tasked with parsing out xml and json data into an application. I am trying to create a properties class that encompasses all the data I will be collecting. Here is my issue/question I have created a class with the variables for the weather data, temp, wind, uv index, etc. I have created the days as well. I can access the days individually but not as a whole. For example. ``` Monday m = new Monday(); m.TempHiF = "65"; ``` What I want to do is this. ``` WDay d = new WDay(); d.Monday.TempHiF = "65" d.Tuesday.TempHiF = "67"; ``` And so on. I am pretty new to C# and I am not even sure what to google. I have been racking my brain for a week and come up with limited success. I am open to other suggestions on storing the data as well.

Original source