PropertyCollection.IDictionary.Contains(Object) 方法

定义

确定 IDictionary 对象是否包含具有指定键的元素。

 virtual bool System.Collections.IDictionary.Contains(System::Object ^ value) = System::Collections::IDictionary::Contains;
bool IDictionary.Contains (object value);
abstract member System.Collections.IDictionary.Contains : obj -> bool
override this.System.Collections.IDictionary.Contains : obj -> bool
Function Contains (value As Object) As Boolean Implements IDictionary.Contains

参数

value
Object

要在 IDictionary 对象中查找的键。

返回

如果 true 包含具有键的元素,则为 IDictionary;否则为 false

实现

例外

keynull

示例

以下示例演示如何实现 Contains 方法。 此示例是为 类提供的更大示例的一 IDictionary 部分。

public:
    virtual bool Contains(Object^ key)
    {
        int index;
        return TryGetIndexOfKey(key, &index);
    }
public bool Contains(object key)
{
   Int32 index;
   return TryGetIndexOfKey(key, out index);
}
Public Function Contains(ByVal key As Object) As Boolean Implements IDictionary.Contains
    Dim index As Integer
    Return TryGetIndexOfKey(key, index)
End Function

适用于