How to add duplicate keys into the Dictionary

后端 未结 6 626
闹比i
闹比i 2021-01-31 17:37

I have some lines from text files that i want to add into the Dictionary.I am using Dictionary for the first time.While adding up starting lines it was Ok but suddenly i got err

6条回答
  •  执笔经年
    2021-01-31 18:23

    Its not possible to add duplicate items to a Dictionary - an alternative is to use the Lookup class.

    Enumerable.ToLookup Method

    Creates a generic Lookup from an IEnumerable.

提交回复
热议问题