I have a Dictionary with 5 different doubles in the list. I know the order of each item in the List. I am trying to find a one liner piece of code where I can lookup a specific value in my list given the key.
So something like:
double myDbl = myDict["key"][value[3]];
Is something like this possible, I cant find it anywhere. Thanks
As others have said, if this is a
Dictionary<string, List<double>>you could just useHowever, this line:
makes me think that actually you should restructure your code. If you know that the first item always represents one piece of data (e.g. weight), the next always represents another (e.g. height) etc, then you should just create a new type with those properties. Using a
List<double>for this will make the code much harder to maintain… it doesn’t naturally reveal the information about what each value means.Once you’ve changed it to, say, a
Dictionary<string, Person>you can use:which is significantly clearer.
Of course it’s possible that you meant something else by the line I’ve quoted…