Answers:
List<string> keyList = new List<string>(this.yourDictionary.Keys);yourDictionary对象是对象的一部分,从函数派生的名称还是参数名称的混淆。
                    您应该可以看一下.Keys:
    Dictionary<string, int> data = new Dictionary<string, int>();
    data.Add("abc", 123);
    data.Add("def", 456);
    foreach (string key in data.Keys)
    {
        Console.WriteLine(key);
    }获取所有键的列表
using System.Linq;
List<String> myKeys = myDict.Keys.ToList();.Net Framework 3.5或更高版本支持System.Linq。如果在使用System.Linq时遇到任何问题,请参见以下链接
using System.Linq;我需要知道忽略哪些答案。抱歉:)
                    .ToList()这么多次使用它会引发错误,所以我来到这里寻找答案,我意识到我正在使用的文件没有using System.Linq:)
                    Dictionary<string, object>.KeyCollection' does not contain a definition for 'ToList'
                    马克·格雷夫(Marc Gravell)的答案应该对您有用。myDictionary.Keys返回一个对象实现ICollection<TKey>,IEnumerable<TKey>和他们非通用同行。
我只是想补充一下,如果您还打算访问该值,则可以像这样遍历字典(修改后的示例):
Dictionary<string, int> data = new Dictionary<string, int>();
data.Add("abc", 123);
data.Add("def", 456);
foreach (KeyValuePair<string, int> item in data)
{
    Console.WriteLine(item.Key + ": " + item.Value);
}或像这样:
List< KeyValuePair< string, int > > theList =
    new List< KeyValuePair< string,int > >(this.yourDictionary);
for ( int i = 0; i < theList.Count; i++)
{ 
  // the key
  Console.WriteLine(theList[i].Key);
}