Can't add keyValuePair directly to Dictionary

后端 未结 8 1115
半阙折子戏
半阙折子戏 2020-12-18 18:45

I wanted to add a KeyValuePair to a Dictionary and I couldn\'t. I have to pass the key and the value separately, which must

8条回答
  •  自闭症患者
    2020-12-18 19:01

    just because the enumerator for the Dictionary class returns a KeyValuePair, does not mean that is how it is implemented internally.

    use IDictionary if you really need to pass KVP's because you've already got them in that format. otherwise use assignment or just use the Add method.

提交回复
热议问题