无法将“System.Collections.DictionaryEntry”类型的对象转换为“System.String”类型

Ahm*_*med 3 c# resources

我有资源Resource1有很多字符串 doc1,doc2,...等我想检索列表中此资源中的所有内容 我编写了以下代码但是在foreach循环时给我一个异常这是我的代码

     ResourceSet resourceSet =  Resource1.ResourceManager.GetResourceSet(
CultureInfo.CurrentUICulture, true, true);
    List<string> Data_set = new List<string>();

foreach (string xs in resourceSet)
        {
            Data_set.Add(xs);

        }
        listBox1.DataSource = Data_set;
Run Code Online (Sandbox Code Playgroud)

vin*_*ntp 5

你不能投射DictionaryEntrystring,但你可以得到它的Keyor Value

foreach (DictionaryEntry xs in resourceSet)
{
    Data_set.Add(xs.Key + " " + xs.Value);
}
Run Code Online (Sandbox Code Playgroud)