Show / Hide Table of Contents

    Class DictionaryExtensions

    Extension methods for the System.Collections.Generic.Dictionary<TKey, TValue>.

    Inheritance
    System.Object
    DictionaryExtensions
    Namespace: Cuemon.Collections.Generic
    Assembly: Cuemon.Core.dll
    Syntax
    public static class DictionaryExtensions

    Methods

    | Improve this Doc

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

    Gets the value associated with the specified key or default(TValue) when the key does not exists in the dictionary.

    Declaration
    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
    Parameters
    Type Name Description
    System.Collections.Generic.IDictionary<TKey, TValue> dictionary

    The dictionary to extend.

    TKey key

    The key of the value to get.

    Returns
    Type Description
    TValue

    Either the value associated with the specified key or default(TValue) when the key does not exists.

    Type Parameters
    Name Description
    TKey

    The type of the keys in the dictionary.

    TValue

    The type of the values in the dictionary.

    | Improve this Doc

    GetValueOrDefault<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TValue>)

    Gets the value associated with the specified key or a default value through defaultProvider when the key does not exists in the dictionary.

    Declaration
    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TValue> defaultProvider)
    Parameters
    Type Name Description
    System.Collections.Generic.IDictionary<TKey, TValue> dictionary

    The dictionary to extend.

    TKey key

    The key of the value to get.

    System.Func<TValue> defaultProvider

    The function delegate that will provide a default value when the key does not exists in the dictionary.

    Returns
    Type Description
    TValue

    Either the value associated with the specified key or a default value through defaultProvider when the key does not exists.

    Type Parameters
    Name Description
    TKey

    The type of the keys in the dictionary.

    TValue

    The type of the values in the dictionary.

    | Improve this Doc

    TryGetValue<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<IEnumerable<TKey>, TKey>, out TValue)

    Gets the value associated with the specified key.

    Declaration
    public static bool TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<IEnumerable<TKey>, TKey> keySelector, out TValue value)
    Parameters
    Type Name Description
    System.Collections.Generic.IDictionary<TKey, TValue> dictionary

    The dictionary to extend.

    TKey key

    The key of the value to get.

    System.Func<System.Collections.Generic.IEnumerable<TKey>, TKey> keySelector

    The function delegate that will resolve an alternate key from the specified key.

    TValue value

    When this method returns, contains the value associated with the specified key or the alternate key resolved from keySelector, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

    Returns
    Type Description
    System.Boolean

    true if the dictionary contains an element with the specified key or the alternate key resolved from keySelector, false otherwise.

    Type Parameters
    Name Description
    TKey

    The type of the keys in the dictionary.

    TValue

    The type of the values in the dictionary.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX