PropertyCollection.IDictionary.Contains(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether the IDictionary object contains an element with the specified key.
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
Parameters
- value
- Object
The key to locate in the IDictionary object.
Returns
true
if the IDictionary contains an element with the key; otherwise, false
.
Implements
Exceptions
key
is null
.
Examples
The following example demonstrates how to implement the Contains method. This example is part of a larger example provided for the IDictionary class.
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
Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.