我使用第三方库,我未能够获得对象数组内容访问对象为字典
IDictionary dic=SomeFunc(); // this function returns an IDictionary
和我使用的DictionaryEntry来获得它的内容
foreach(DictionaryEntry de in dic)
{
//each of de.Value is implemented as a KeyValuePair<object,object>
//I have not yet learned how to read each de.Value's key and value pair
}
你能不能给我提示获取de.Value中的字符串,这是一个对象的字典对象?
编辑 de.Values的每个值都是“object”到“object”类型的键值对。它会报告错误,当我将它转换为字符串
foreach (DictionaryEntry de in dic)
{
foreach(KeyValuePair<string,string> k in (Dictionary<string,string>)de.Values)
{
//error: instance is null
}
}
不要忘记为接受的标记答案,如果你有信息想要 – 2012-01-18 07:00:34