我想提取出相同值所对应的索引:            Dictionary<string, string> myDic = new Dictionary<string, string>();
            myDic.Add("aaa", "111");
            myDic.Add("bbb", "222");
            myDic.Add("ccc", "333");
            myDic.Add("ddd", "111");
            mydic.Add("eee", "666");
我想得到相同值所对应的索引值,即上面111两个分别对应的索引,最好存放于一个集合List或dictionary中,请赐教。
谢谢  

解决方案 »

  1.   

    应该只有遍历Values
    判断吧
      

  2.   

    for each 循环吧
    好像没有这样的泛型委托
      

  3.   


            static List<string> GetKeysFromValue(Dictionary<string, string> dic, string value)
            {
                List<string> list = new List<string>();
                IDictionaryEnumerator ide = dic.GetEnumerator();
                while (ide.MoveNext())
                {
                    if (ide.Value.ToString() == value)
                        list.Add(ide.Key.ToString());
                }
                return list;
            }