Search Results for

    Show / Hide Table of Contents

    Class DictionaryExtensions

    Represents a series of Dictionary extension methods.

    Inheritance
    object
    DictionaryExtensions
    Namespace: TriLibCore.Extensions
    Assembly: TriLibCore.Source.dll
    Syntax
    public static class DictionaryExtensions

    Methods

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

    Declaration
    public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary
    TKey key
    TValue defaultValue
    Returns
    Type Description
    TValue
    Type Parameters
    Name Description
    TKey
    TValue

    TryAdd<TKey, TValue>(Dictionary<TKey, TValue>, TKey, TValue)

    Declaration
    public static bool TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary
    TKey key
    TValue value
    Returns
    Type Description
    bool
    Type Parameters
    Name Description
    TKey
    TValue

    TryGetValueSafe<TKey, TValue>(IDictionary<TKey, TValue>, TKey, out TValue)

    Tries to get a value in the given Dictionary without throwing Exceptions.

    Declaration
    public static bool TryGetValueSafe<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, out TValue value)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> dictionary

    The Dictionary.

    TKey key

    The Dictionary key.

    TValue value

    The Dictionary value.

    Returns
    Type Description
    bool

    true if the given Key is found. Otherwise, false.

    Type Parameters
    Name Description
    TKey

    The Dictionary Key type.

    TValue

    The Dictionary Value type.

    In this article
    Back to top TriLib documentation