System::Collections::Generic::IDictionary 类

IDictionary class

字典类容器的接口。此类的对象只能使用 System::MakeObject() 函数分配。切勿在栈上或使用 operator new 创建此类型的实例,因为这会导致运行时错误和/或断言故障。始终将此类包装到 System::SmartPtr 指针中,并使用该指针将其作为参数传递给函数。

template<typename TKey,typename TValue>class IDictionary : public System::Collections::Generic::ICollection<KeyValuePair<TKey, TValue>>
参数描述
TKey密钥类型。
TValue值类型。

方法

方法描述
virtual Add(const TKey&, const TValue&)向容器中添加键值对。
virtual ContainsKey(const TKey&) const检查容器是否包含键。
CopyTo(ArrayPtr<KeyValuePair<TKey, TValue>>, int) override将字典内容复制到现有数组元素中。
virtual get_Count() const取消隐藏 get_Count 成员函数。
get_IsFixedSize() const检查集合大小是否固定。
get_IsSynchronized() const检查容器是否线程安全。
virtual get_Keys() const访问键集合。
virtual get_Values() const访问值集合。
virtual GetValueOrDefault(const TKey&) const如果找到则返回值;否则返回 Value()
virtual GetValueOrDefault(const TKey&, const TValue&) const如果找到则返回值;否则返回 defaultValue
virtual GetValueOrNull(const TKey&) const如果找到则返回值;否则返回 null,仅对引用类型有意义。
virtual idx_get(const TKey&) const获取函数。
virtual idx_set(const TKey&, TValue)设置函数。
virtual Remove(const TKey&)从容器中移除键。
virtual TryGetValue(const TKey&, TValue&) const查找值并在找到时检索它。

Typedefs

类型定义描述
BaseTypeRTTI 信息。
KeyValuePairType键值对类型。

另见