CollectionExtensions.GetValueOrDefault 메서드
정의
오버로드
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) |
|
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) |
지정된 키에 연결된 값을 |
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)
dictionary
에서 지정된 key
와 연결된 값을 가져오려고 시도합니다.Tries to get the value associated with the specified key
in the dictionary
.
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);
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
사전에 있는 키의 형식입니다.The type of the keys in the dictionary.
- TValue
사전에 있는 값의 형식입니다.The type of the values in the dictionary.
매개 변수
- dictionary
- IReadOnlyDictionary<TKey,TValue>
TKey
형식의 키와 TValue
형식의 값이 있는 사전입니다.A dictionary with keys of type TKey
and values of type TValue
.
- key
- TKey
가져올 값의 키입니다.The key of the value to get.
반환
TValue
인스턴스입니다.A TValue
instance. 메서드가 성공적으로 실행되면 반환되는 개체는 지정된 key
과 연결된 값입니다.When the method is successful, the returned object is the value associated with the specified key
. 메서드가 실패하면 TValue
에 대한 default
값을 반환합니다.When the method fails, it returns the default
value for TValue
.
예외
dictionary
가 null
인 경우dictionary
is null
.
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)
지정된 키에 연결된 값을 dictionary
에서 가져오려고 시도합니다.Tries to get the value associated with the specified key in the dictionary
.
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
사전에 있는 키의 형식입니다.The type of the keys in the dictionary.
- TValue
사전에 있는 값의 형식입니다.The type of the values in the dictionary.
매개 변수
- dictionary
- IReadOnlyDictionary<TKey,TValue>
TKey
형식의 키와 TValue
형식의 값이 있는 사전입니다.A dictionary with keys of type TKey
and values of type TValue
.
- key
- TKey
가져올 값의 키입니다.The key of the value to get.
- defaultValue
- TValue
dictionary
가 지정된 key
와 연결된 값을 찾을 수 없는 경우 반환할 기본값입니다.The default value to return when the dictionary
cannot find a value associated with the specified key
.
반환
TValue
인스턴스입니다.A TValue
instance. 메서드가 성공적으로 실행되면 반환되는 개체는 지정된 key
과 연결된 값입니다.When the method is successful, the returned object is the value associated with the specified key
. 메서드가 실패하면 defaultValue
가 반환됩니다.When the method fails, it returns defaultValue
.
예외
dictionary
가 null
입니다.dictionary
is null
.