What is the best .NET type for collections where each key can have multiple values?

前端 未结 4 905
隐瞒了意图╮
隐瞒了意图╮ 2021-02-15 23:34

I have one key but different values for that key. I tried HashTable but I don\'t think that is the right way of doing it.

I\'ll explain in detail what the requirement i

4条回答
  •  执念已碎
    2021-02-16 00:01

    You could use a Dictionary>:

    var dictionary = new Dictionary>();
    dictionary.Add("asp.net", new List());
    dictionary["asp.net"].Add(61);
    dictionary["asp.net"].Add(67);
    dictionary["asp.net"].Add(100);
    

提交回复
热议问题