System.Collections.Specialized.OrderedDictionary Dic = new System.Collections.Specialized.OrderedDictionary();
            Dic.Add("a", "aaa");
            Dic.Add("b", "bbb");
            Dic.Keys
:
因为Dic.Keys 类型[反射后查得]为 一个私有类System.Collections.Specialized.OrderedDictionary.OrderedDictionaryKeyValueCollection
求 获得keys列表的方法

解决方案 »

  1.   

    什么是私有类?
    Keys是OrderedDictionary的公共属性,ICollection接口类型的
      

  2.   

    我剛查過msdn2005,裡面的keys是public的。
      

  3.   

    public ICollection Keys { get; }
    获取 ICollection 对象,该对象包含 OrderedDictionary 集合中的键。
      

  4.   

    TO:因为Dic.Keys 类型[反射后查得]为 一个私有类System.Collections.Specialized.OrderedDictionary.OrderedDictionaryKeyValueCollection
    求 获得keys列表的方法不就直接Dic.Keys就可以了吗?它是公共的属性...
      

  5.   

    参见MSDN:ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.NETDEVFX.v20.chs/cpref2/html/P_System_Collections_Specialized_OrderedDictionary_Keys.htmexample like :// Creates and initializes a OrderedDictionary.
    OrderedDictionary myOrderedDictionary = new OrderedDictionary();
    myOrderedDictionary.Add("testKey1", "testValue1");
    myOrderedDictionary.Add("testKey2", "testValue2");
    myOrderedDictionary.Add("keyToDelete", "valueToDelete");
    myOrderedDictionary.Add("testKey3", "testValue3");ICollection keyCollection = myOrderedDictionary.Keys;
    ICollection valueCollection = myOrderedDictionary.Values;// Display the contents using the key and value collections
    DisplayContents(keyCollection, valueCollection, myOrderedDictionary.Count);
      

  6.   

    try.. OrderedDictionary myOrderedDictionary = new OrderedDictionary();
                myOrderedDictionary.Add("testKey1", "testValue1");
                myOrderedDictionary.Add("testKey2", "testValue2");
                myOrderedDictionary.Add("keyToDelete", "valueToDelete");
                myOrderedDictionary.Add("testKey3", "testValue3");
                string[] mykeys = new string[myOrderedDictionary.Count];
                string[] myvalues = new string[myOrderedDictionary.Count];
                myOrderedDictionary.Keys.CopyTo(mykeys, 0);
                myOrderedDictionary.Values.CopyTo(myvalues, 0);
                for (int i = 0; i < myOrderedDictionary.Count; i++)
                {
                    Console.WriteLine("Key: " + mykeys[i] + "\tValue: " + myvalues[i]);
                }输出:
    Key: testKey1 Value: testValue1
    Key: testKey2 Value: testValue2
    Key: keyToDelete Value: valueToDelete
    Key: testKey3 Value: testValue3
      

  7.   

    to liujia_0421(SnowLover)
    如果用了数组的话,就用不了面向对象