IDictionary<TKey,TValue>.Remove(TKey) 메서드

정의

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

제거할 요소의 키입니다.

반환

Boolean

요소가 제거되면 true이고, 그렇지 않으면 false입니다. 이 메서드는 key가 원래 IDictionary<TKey,TValue>에 없는 경우에도 false를 반환합니다.

예외

key이(가) null인 경우

IDictionary<TKey,TValue>이 읽기 전용인 경우

예제

다음 코드 예제에서는 메서드를 사용 하 여 사전에서 키/값 쌍을 제거 하는 Remove 방법을 보여 있습니다.

이 코드는 컴파일 및 실행할 수 있는 더 큰 예제의 일부입니다. 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> 수 있습니다.

적용 대상

추가 정보