IDictionary<TKey,TValue>.Remove(TKey) 메서드
정의
IDictionary<TKey,TValue>에서 지정한 키를 가지는 요소를 제거합니다.Removes the element with the specified key from the IDictionary<TKey,TValue>.
public:
bool Remove(TKey key);
public bool Remove (TKey key);
abstract member Remove : 'Key -> bool
Public Function Remove (key As TKey) As Boolean
매개 변수
- key
- TKey
제거할 요소의 키입니다.The key of the element to remove.
반환
요소가 제거되면 true
이고, 그렇지 않으면 false
입니다.true
if the element is successfully removed; otherwise, false
. 이 메서드는 key
가 원래 IDictionary<TKey,TValue>에 없는 경우에도 false
를 반환합니다.This method also returns false
if key
was not found in the original IDictionary<TKey,TValue>.
예외
key
이(가) null
인 경우key
is null
.
IDictionary<TKey,TValue>이 읽기 전용인 경우The IDictionary<TKey,TValue> is read-only.
예제
다음 코드 예제에서는 메서드를 사용 하 여 사전에서 키/값 쌍을 제거 하는 방법을 보여 줍니다 Remove .The following code example shows how to remove a key/value pair from a dictionary using the Remove method.
이 코드는 컴파일 및 실행할 수 있는 더 큰 예제의 일부입니다.This code is part of a larger example that can be compiled and executed. System.Collections.Generic.IDictionary<TKey,TValue>을 참조하세요.See System.Collections.Generic.IDictionary<TKey,TValue>.
// Use the Remove method to remove a key/value pair.
Console::WriteLine("\nRemove(\"doc\")");
openWith->Remove("doc");
if (!openWith->ContainsKey("doc"))
{
Console::WriteLine("Key \"doc\" is not found.");
}
// Use the Remove method to remove a key/value pair.
Console.WriteLine("\nRemove(\"doc\")");
openWith.Remove("doc");
if (!openWith.ContainsKey("doc"))
{
Console.WriteLine("Key \"doc\" is not found.");
}
' Use the Remove method to remove a key/value pair.
Console.WriteLine(vbLf + "Remove(""doc"")")
openWith.Remove("doc")
If Not openWith.ContainsKey("doc") Then
Console.WriteLine("Key ""doc"" is not found.")
End If
설명
구현은 개체의 같음 여부를 결정 하는 방법에 따라 달라질 수 있습니다. 예를 들어 클래스는 List<T> 를 사용 하는 Comparer<T>.Default 반면, 클래스를 사용 하면 Dictionary<TKey,TValue> 사용자가 IComparer<T> 키를 비교 하는 데 사용할 구현을 지정할 수 있습니다.Implementations can vary in how they determine equality of objects; for example, the List<T> class uses Comparer<T>.Default, whereas the Dictionary<TKey,TValue> class allows the user to specify the IComparer<T> implementation to use for comparing keys.