IDictionary.Contains(Object) 메서드
정의
IDictionary 개체에 지정한 키를 가진 요소가 포함되어 있는지 여부를 결정합니다.Determines whether the IDictionary object contains an element with the specified key.
public:
bool Contains(System::Object ^ key);
public bool Contains (object key);
abstract member Contains : obj -> bool
Public Function Contains (key As Object) As Boolean
매개 변수
- key
- Object
IDictionary 개체에서 찾을 키입니다.The key to locate in the IDictionary object.
반환
true
에 해당 키가 있는 요소가 포함되어 있으면 IDictionary이고, 그렇지 않으면 false
입니다.true
if the IDictionary contains an element with the key; otherwise, false
.
예외
key
이(가) null
인 경우key
is null
.
예제
다음 코드 예제를 구현 하는 방법에 설명 합니다 Contains 메서드.The following code example demonstrates how to implement the Contains method. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 IDictionary 클래스입니다.This code 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
설명
구현은 키를 허용 하는지 여부에 따라 달라질 수 있습니다 null
.Implementations can vary in whether they allow the key to be null
.
.NET Framework 2.0부터이 메서드는 컬렉션의 개체와의 메서드를 사용 하 여 Equals CompareTo item
가 있는지 여부를 확인 item
합니다.Starting with the .NET Framework 2.0, this method uses the collection's objects' Equals and CompareTo methods on item
to determine whether item
exists. 이전 버전의 .NET Framework에서는 Equals CompareTo item
컬렉션의 개체에 대 한 매개 변수의 및 메서드를 사용 하 여 이러한 결정을 수행 했습니다.In the earlier versions of the .NET Framework, this determination was made by using the Equals and CompareTo methods of the item
parameter on the objects in the collection.