本文介绍了如何使用Toarray()" System.Collections.Generic.Dictionary"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(pdfReader);
// var v = bookmarks.OfType <string>().ToArray();
for (int i = 0; i < bookmarks.Count; i++)
{
MessageBox.Show(bookmarks[i].Values.ToArray().GetValue(0).ToString());
但它在转换中显示错误 Toarray
错误 - 'System.Collections.Generic.Dictionary< string,object> .ValueCollection'不包含'ToArray'的定义,也没有扩展方法'ToArray '接受第一个类型的参数
请帮忙。
But It showing error in conversion Toarray
Error -- "'System.Collections.Generic.Dictionary<string,object>.ValueCollection' does not contain a definition for 'ToArray' and no extension method 'ToArray' accepting a first argument of type "
Please Help.
推荐答案
Dictionary<string, object> d = new Dictionary<string, object>();
for (int ii = 1; ii < 10; ii++)
d.Add((ii * 111).ToString(), ii * 11);
Console.WriteLine(d[d.Keys.ToArray()[0]]);
Console.WriteLine(d.Values.ToArray()[0]);
IList<Dictionary<string, object>> bookmarks = new List<Dictionary<string, object>>();
bookmarks.Add(d);
int i = 0;
Console.WriteLine(bookmarks[i].Values.ToArray().GetValue(0).ToString());
编译并运行完美...
那么我在做什么呢和你不一样?
And it compiled and ran perfectly...
So what am I doing that is different from you?
这篇关于如何使用Toarray()" System.Collections.Generic.Dictionary"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!