小编use*_*847的帖子

Dictionary <string,List <int >>复制到另一个Dictionary

我有一个问题,将数字的值复制到另一个字典.一切顺利,但是如果密钥已经存在,我只要将List中的值添加到另一个字典中.我不明白如何将相同的值添加到字典以及通过.

   foreach (KeyValuePair<string, List<int>> record in dictonaryUnStem)

        {
            arrayWord = record.Key.ToCharArray();
            st.add(arrayWord);
            stemWord = st.stem();

            if (!dictonaryStem.ContainsKey(stemWord))
            {
                dictonaryStem.Add(stemWord, record.Value);
            }
            else
            {
                foreach (int i in record.Value)
                {
                    dictonaryStem[stemWord].Add(i);
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

从给定的键整数添加到另一个字典时.我们加入了我的记录,也是整数字典UnStem.这是完全不合逻辑的.

stemWord = st.stem() 
Run Code Online (Sandbox Code Playgroud)

给我根词,这是第一本词典中的关键词.在列表中存储该文本中的单词的位置.

c# dictionary

2
推荐指数
1
解决办法
623
查看次数

标签 统计

c# ×1

dictionary ×1