How to map a hash key with a list of values in c#?
I have a string member variable namely ServiceType and a string list SubService .
Here serviceType contains strings(consider as key) and SubService contains list of
strings(consider as value). Now i'm trying to map one Servic开发者_如何转开发eType string(key) with
SubService(value contains list of strings) using hashing concept. what my problem is i can map
a key with one value but i'm not getting that how to map with list of values.Anyone can help
me that hoe to map this kind of list and key in c#
I guess you need Dictionary<string, List<string>>
MSDN
I don't have Visual Studio open in front of me, so this probably has some syntax issues, but basically:
Dictionary<string, List<string>> foo = new Dictionary<string, List<string>>();
// populate
List<string> bar = new List<string>();
bar.Add("wheeeee");
foo.Add("myKeyValue", bar);
// fetch
List<string> myServices = foo["myKeyValue"];
精彩评论