Hashtable with multiple values for single key

后端 未结 11 1556
渐次进展
渐次进展 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条回答
  •  猫巷女王i
    2021-02-13 14:20

    That throws an error because you're adding the same key twice. Try using a Dictionary instead of a HashTable.

    Dictionary> values = new Dictionary>();
    IList list = new List()
    {
        "test", "Test1"
    };
    values.Add(1, list);
    

提交回复
热议问题