Hashtable with multiple values for single key

后端 未结 11 1525
渐次进展
渐次进展 2021-02-13 13:36

I want to store multiple values in single key like:

HashTable obj = new HashTable();
obj.Add(\"1\", \"test\");
obj.Add(\"1\", \"Test1\");

Right

11条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 14:02

    Store a list in the hashtable:

    obj.Add("1",new List());
    (obj["1"] as List).Add("test");
    (obj["1"] as List).Add("test1");
    

    This is a common trick.

提交回复
热议问题