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

前端 未结 4 1735
眼角桃花
眼角桃花 2021-02-15 23:05

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:00

    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);
    

提交回复
热议问题