I’m looking to make a custom data structure that holds a schedule for a particular class in a 5-course course load in university. It doesn’t matter to me what year and date the classes are taking place – I only care about the day of the week and the time that it takes place.
How can I represent this without the DateTime? Or is there a way to do this with it?
Thanks.
Create your own class that holds the bits of data that are important for you.
The
DayOfWeekenumeration is suitable to hold the day of the week and you can model the hours/minutes withintfields.Something like:
You need to ensure that the values passed in valid (say hours can be between
0and23, minutes between0and59and that the enum value passed in is actually a valid enum value.I suggest making this an immutable value type.