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

정의

SortedDictionary<TKey,TValue>에서 지정한 키를 가지는 요소를 제거합니다.

public:
 virtual bool Remove(TKey key);
public bool Remove (TKey key);
abstract member Remove : 'Key -> bool
override this.Remove : 'Key -> bool
Public Function Remove (key As TKey) As Boolean

매개 변수

key
TKey

제거할 요소의 키입니다.

반환

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

구현

예외

key이(가) null인 경우

예제

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

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SortedDictionary<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(vbLf + "Remove(""doc"")")
openWith.Remove("doc")

If Not openWith.ContainsKey("doc") Then
    Console.WriteLine("Key ""doc"" is not found.")
End If

설명

SortedDictionary<TKey,TValue> 지정된 키가 있는 요소가 없으면 는 SortedDictionary<TKey,TValue> 변경되지 않은 상태로 유지됩니다. 예외는 throw되지 않습니다.

이 메서드는 O(로그 n) 작업입니다.

적용 대상

추가 정보