So, you can get a single dictionary[key]
value or all dictionary.Values
values.
What I'm looking for is a way to get all the values ββfor a given set of keys as follows:
List<string> keys; Dictionary<string, object> dictionary; List<object> valuesForKeys = GetValuesFromDictionaryUsingKeys(dictionary, keys);
from
private List<object> GetValuesFromDictionaryUsingKeys(Dictionary<string, object> dictionary, List<string> keys) {
Of course, I could manually iterate over the list of keys and use dictionary[key]
every time and again to add all the values ββto the list, but I would like to use a more elegant way (for example, Linq).
Thanks.
source share