Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: TValue? Get<TKey, TValue>(this IDictionary<TKey, TValue>, TKey, TValue?)

Declaration

public static TValue? Get<TKey, TValue>(
    this IDictionary<TKey, TValue> dict,
    TKey key,
    TValue? defaultVal = null
)

Summary

Gets a value from a dictionary by key. If the key does not exist in the dictionary, the default value is returned instead.

Generic type parameters

TKeyThis type parameter is not documented.
TValue
  • Must derive from: System.ValueType.
  • Must have a default constructor.
  • Must be a non-nullable value type.
This type parameter is not documented.

Parameters

this IDictionary<TKey, TValue>dict Dictionary to operate on.
TKeykey Key to look up.
TValue?defaultVal Value to return if key is not contained in the dictionary.