Dictionary<TKey,TValue>.Remove 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
오버로드
| Name | Description |
|---|---|
| Remove(TKey) |
지정된 키를 가진 값을 .에서 Dictionary<TKey,TValue>제거합니다. |
| Remove(TKey, TValue) |
지정된 키를 Dictionary<TKey,TValue>가진 값을 제거하고 요소를 매개 변수에 |
Remove(TKey)
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
지정된 키를 가진 값을 .에서 Dictionary<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 이 메서드는 .에서 찾을 수 없는 경우 false 반환 key 합니다Dictionary<TKey,TValue>.
구현
예외
key은 null입니다.
예제
다음 코드 예제에서는 메서드를 사용 하 여 사전에서 키/값 쌍을 제거 하는 방법을 보여 있습니다 Remove .
이 코드 예제는 클래스에 Dictionary<TKey,TValue> 대해 제공되는 더 큰 예제의 일부입니다(openWith 이 예제에 사용된 사전의 이름).
// 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.
printfn "\nRemove(\"doc\")"
openWith.Remove "doc" |> ignore
if openWith.ContainsKey "doc" |> not then
printfn "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
설명
Dictionary<TKey,TValue> 지정된 키를 Dictionary<TKey,TValue> 가진 요소가 없으면 변경되지 않은 상태로 유지됩니다. 예외가 던져지지 않습니다.
이 메서드는 O(1) 작업에 접근합니다.
.NET Core 3.0 이상만 해당: 이 변경 메서드는 인스턴스에서 Dictionary<TKey,TValue> 활성 열거자를 무효화하지 않고 안전하게 호출할 수 있습니다. 스레드 안전을 의미하지는 않습니다.
추가 정보
적용 대상
Remove(TKey, TValue)
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
- Source:
- Dictionary.cs
지정된 키를 Dictionary<TKey,TValue>가진 값을 제거하고 요소를 매개 변수에 value 복사합니다.
public:
bool Remove(TKey key, [Runtime::InteropServices::Out] TValue % value);
public bool Remove(TKey key, out TValue value);
member this.Remove : 'Key * 'Value -> bool
Public Function Remove (key As TKey, ByRef value As TValue) As Boolean
매개 변수
- key
- TKey
제거할 요소의 키입니다.
- value
- TValue
제거된 요소입니다.
반품
true요소를 성공적으로 찾아서 제거하면 이고, 그렇지 않으면 . false
예외
key은 null입니다.