需要Hashtable和Arraylist [英] Need Hashtable and Arraylist

查看:285
本文介绍了需要Hashtable和Arraylist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows 7 Phone应用程序中使用别人的C#类。这些类使用类型为Hashtable的对象。



有关文件

 使用System.Collections;在顶部的

,所以我假设这是它想要的Hashtable对象。



当我尝试构建我的解决方案时,我收到类型或命名空间名称Hashtable无法找到的错误,您是否缺少using指令或程序集引用。



在Microsoft的Hashtable文档中,我看到它说Assembly:mscorlib



但是,如果我尝试添加mscorlib通过项目>添加参考,VS说它不能添加它,因为它被构建系统自动引用。



我缺少什么?

解决方案

非泛型集合,包括 ArrayList HashTable 不包括在Silverlight中。

这些类是.Net 1.0(没有泛型)的保持,不应该用于新的代码。



相反,您应该使用通用集合— 列表< T> 字典< TKey,TValue&


I am trying to use someone else's C# classes in my Windows 7 Phone app. The classes use objects of type Hashtable.

The file in question has

using System.Collections;

at the top, so I'm assuming that's the Hashtable object it wants.

When I try to build my solution, I get errors that the type or namespace name 'Hashtable' could not be found, are you missing a using directive or assembly reference.

In Microsoft's documentation of Hashtable, I see it says Assembly: mscorlib

But if I try to add mscorlib via Project>Add Reference, VS says it can't add it because it is automatically referenced by the build system.

What am I missing?

解决方案

The non-generic collections, including ArrayList and HashTable, are not included in Silverlight.
These classes are hold-overs from .Net 1.0 (which didn't have generics) and should not be used in new code.

Instead, you should use the generic collections—List<T> and Dictionary<TKey, TValue>.

这篇关于需要Hashtable和Arraylist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆