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

정의

지정된 키를 가진 요소를 .에서 SortedList<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 또한 이 메서드는 원래 SortedList<TKey,TValue>메서드에서 찾을 수 없는 경우에도 key 반환 false 합니다.

구현

예외

keynull입니다.

예제

다음 코드 예제에서는 메서드를 사용하여 정렬된 목록에서 키/값 쌍을 Remove 제거하는 방법을 보여줍니다.

이 코드 예제는 클래스에 제공된 더 큰 예제의 SortedList<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
// Use the Remove method to remove a key/value pair.
printfn "\nRemove(\"doc\")"
openWith.Remove("doc") |> ignore

if not (openWith.ContainsKey("doc")) then
    printfn "Key \"doc\" is not found."

설명

이 메서드는 이진 검색을 수행합니다. 그러나 요소가 열린 지점을 채우기 위해 위로 이동되므로 이 메서드는 O(n) 연산입니다. 여기서 n 는 다음과 같습니다 Count.

적용 대상

추가 정보