CollectionExtensions.GetValueOrDefault 메서드

정의

오버로드

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)

dictionary에서 지정된 key과(와) 연결된 값을 가져오려고 시도합니다.

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)

dictionary에서 지정된 key과(와) 연결된 값을 가져오려고 시도합니다.

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)

Source:
CollectionExtensions.cs
Source:
CollectionExtensions.cs
Source:
CollectionExtensions.cs

dictionary에서 지정된 key과(와) 연결된 값을 가져오려고 시도합니다.

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue GetValueOrDefault(System::Collections::Generic::IReadOnlyDictionary<TKey, TValue> ^ dictionary, TKey key);
public static TValue? GetValueOrDefault<TKey,TValue> (this System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> dictionary, TKey key);
public static TValue GetValueOrDefault<TKey,TValue> (this System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> dictionary, TKey key);
static member GetValueOrDefault : System.Collections.Generic.IReadOnlyDictionary<'Key, 'Value> * 'Key -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TKey, TValue) (dictionary As IReadOnlyDictionary(Of TKey, TValue), key As TKey) As TValue

형식 매개 변수

TKey

사전에 있는 키의 형식입니다.

TValue

사전에 있는 값의 형식입니다.

매개 변수

dictionary
IReadOnlyDictionary<TKey,TValue>

TKey 형식의 키와 TValue 형식의 값을 사용하는 사전입니다.

key
TKey

가져올 값의 키입니다.

반환

TValue

TValue 인스턴스입니다. 메서드가 성공적으로 실행되면 반환되는 개체는 지정된 key과(와) 연결된 값입니다. 메서드가 실패하면 TValue에 대한 default 값을 반환합니다.

예외

dictionarynull입니다.

적용 대상

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)

Source:
CollectionExtensions.cs
Source:
CollectionExtensions.cs
Source:
CollectionExtensions.cs

dictionary에서 지정된 key과(와) 연결된 값을 가져오려고 시도합니다.

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue GetValueOrDefault(System::Collections::Generic::IReadOnlyDictionary<TKey, TValue> ^ dictionary, TKey key, TValue defaultValue);
public static TValue GetValueOrDefault<TKey,TValue> (this System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> dictionary, TKey key, TValue defaultValue);
static member GetValueOrDefault : System.Collections.Generic.IReadOnlyDictionary<'Key, 'Value> * 'Key * 'Value -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TKey, TValue) (dictionary As IReadOnlyDictionary(Of TKey, TValue), key As TKey, defaultValue As TValue) As TValue

형식 매개 변수

TKey

사전에 있는 키의 형식입니다.

TValue

사전에 있는 값의 형식입니다.

매개 변수

dictionary
IReadOnlyDictionary<TKey,TValue>

TKey 형식의 키와 TValue 형식의 값을 사용하는 사전입니다.

key
TKey

가져올 값의 키입니다.

defaultValue
TValue

dictionary에서 지정된 key과(와) 연결된 값을 찾을 수 없는 경우 반환할 기본값입니다.

반환

TValue

TValue 인스턴스입니다. 메서드가 성공적으로 실행되면 반환되는 개체는 지정된 key과(와) 연결된 값입니다. 메서드가 실패하면 defaultValue을(를) 반환합니다.

예외

dictionarynull입니다.

적용 대상