IDictionary.Remove(Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
IDictionary 개체에서 지정한 키를 가지는 요소를 제거합니다.
public:
void Remove(System::Object ^ key);
public void Remove (object key);
abstract member Remove : obj -> unit
Public Sub Remove (key As Object)
매개 변수
- key
- Object
제거할 요소의 키입니다.
예외
key
이(가) null
인 경우
예제
다음 코드 예제를 구현 하는 방법에 설명 합니다 Remove 메서드. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 IDictionary 클래스입니다.
public:
virtual void Remove(Object^ key)
{
if (key == nullptr)
{
throw gcnew ArgumentNullException("key");
}
// Try to find the key in the DictionaryEntry array
int index;
if (TryGetIndexOfKey(key, &index))
{
// If the key is found, slide all the items down.
Array::Copy(items, index + 1, items, index, itemsInUse -
index - 1);
itemsInUse--;
}
else
{
// If the key is not in the dictionary, just return.
return;
}
}
public void Remove(object key)
{
if (key == null) throw new ArgumentNullException("key");
// Try to find the key in the DictionaryEntry array
Int32 index;
if (TryGetIndexOfKey(key, out index))
{
// If the key is found, slide all the items up.
Array.Copy(items, index + 1, items, index, ItemsInUse - index - 1);
ItemsInUse--;
}
else
{
// If the key is not in the dictionary, just return.
}
}
Public Sub Remove(ByVal key As Object) Implements IDictionary.Remove
If key = Nothing Then
Throw New ArgumentNullException("key")
End If
' Try to find the key in the DictionaryEntry array
Dim index As Integer
If TryGetIndexOfKey(key, index) Then
' If the key is found, slide all the items up.
Array.Copy(items, index + 1, items, index, (ItemsInUse - index) - 1)
ItemsInUse = ItemsInUse - 1
Else
' If the key is not in the dictionary, just return.
End If
End Sub
설명
IDictionary 개체에 지정한 키를 가진 요소가 없으면 IDictionary가 변경되지 않은 상태로 유지됩니다. 예외는 throw되지 않습니다.