标签:keyvaluepa hashtable c# map key
c#在准备使用System.Collections.Generic.KeyValuePair遍历的Hashtable时候,代码却提示有错误:
这其实是个非常简单的错误,Eclipse中通过工具弹出的提示解决方法,点下鼠标就能解决问题的,Visual Studio 2010却不行。
不过提示也说的比较清楚了,需要指定两个参数的类型。
根据你的Hashtable中保存的Key和Value的数据类型指定就可以了。
例如:
KeyValuePair<string, int>
KeyValuePair<int, int>
KeyValuePair<int, long>
等等,主要看你Hashtable中保存的Key和Value的数据类型,第一个参数对应Key,第二个参数对应Value。
使用泛型 类型System.Collections.Generic.KeyValuePair需要2个类型参数
标签:keyvaluepa hashtable c# map key
原文地址:http://blog.csdn.net/testcs_dn/article/details/45305557