I am brand new to dictionaries and coding and am hoping to get some suggestions on how I should structure my dictionary.
I have a collector number which has meters connected to them. Each of the meters have a meter number and a ert number and would like to store both the meter and ert number. There will be a list of meter reading timestamps and values for each of the meters. Also, I would like to be able to select the values by either the ert number or meter number. I have attached the current structure I have for the dictionary but was wondering if this was the best way to format the dictionary. Someone had suggested objects but I have never worked with objects before.
{
Dictionary<Int32, Dictionary<string, Meter>> dictionary = new Dictionary<int, Dictionary<string, Meter>>();
if (!dictionary.ContainsKey(objectID))
{
dictionary.Add(objectID, new Dictionary<string, Meter>());
}
Meter meter = new Meter();
meter.ertNumber = "9480:1";
meter.meterNumber = "fsadfa";
meter.Reading = new Dictionary<Int32, double>();
meter.Reading.Add(0, 6);
dictionary[objectID].Add("Test", meter);
}
class Meter
{
public String ertNumber { get; set; }
public String meterNumber { get; set; }
public Dictionary<Int32, double> Reading { get; set; }
}
Linq
to find items. I also think that is what that someone meant by 'objects' \$\endgroup\$