I’m attempting to combine 11 different data types into a single list that I can add to and delete from, as well as search for particular values. These data types range involve bool, string, int and double.
The goal is to add updated values to this master list as they come in every minute. For example… at 5:45 pm, 11 new values would be captured from a system. Those 11 values, if passing if/else if challenges, would be added to the master list. These 11 values would be:
- Slot 1 – Time[0].ToString(“HH:mm”); (shown as an example)
- Slot 2 – (data type double)
- Slot 3 – (data type double)
- Slot 4 – (data type double)
- Slot 5 – (data type double)
- Slot 6 – (data type double)
- Slot 7 – (data type double)
- Slot 8 – (data type double)
- Slot 9 – (data type bool)
- Slot 10 – (data type string)
- Slot 11 – (data type double)
If the incoming data didn’t pass the if/else if challenges, then the corresponding list would be reset with all existing data removed from the list.
I’ve gone through different questions here and also via a couple of web searches, but I’m either not understanding how to declare the list or list structures properly, if I should be using classes or arrays, etc.
Those 11 slots you’ve lists seem to be describing a
class. You should create a class that has 11 properties, one for each of your slots. It should have the appropriate data type, as well as a meaningful name (don’t just call it slot1, slot2).That class should have an IsValid method, because it seems that you need to be able to validate a unit of data for this class.
You can then have a collection (Possibly a
List, although you haven’t told us enough about how you’re using it to know if it’s the best fit) of those classes that you can add to (if valid), remove from, and search.