专用集合是预定义集合,用于特殊或专用性很强的场合,这些集合位于System.Collections.Specialized命名空间并且被看作是泛型集合的扩展.要想理解.netFramework为什么提供这些集合,可考虑下列实例并思考将如何做到以下几点:
◆想要使用与 Hashtable 类相似的键/值对来实现一个小型集合以存放最多 10 个元素。
◆想要实现类型安全的 ArrayList来存放字符串值,并为其提供适当的枚举数。
◆要根据键/值对或使用索引位置来访问集合的元素。
◆要创建一个不区分大小写的 SortedList 类。
我们可以通过使用某些具有特定用途的预定义集合来达到上述所有目的。这些预定义的特殊集合称为专用集合,专用集合有以下几种:
◆StringCollection类
◆StringDictionary类
◆StringEnumerator类
◆CollectionUtil类
◆ListDictionary类
◆HybridDictionary类
◆OrderedDictionary类
◆NamueCollection类
//StringCollection类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh{
}
//StringDictionary类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
//StringEnumerator类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
}
//CollectionUtil类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
}
//ListDictionary类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
}
//HybridDictionary类
usingSystem;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
}
//OrderedDictionary类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
}
//NamueCollection类
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh{
}
//使用专用位结构在内存中高效地存储数据
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using System.Collections.Specialized;
namespace zyh
{
}