Search Results for

    Show / Hide Table of Contents

    Class DictionaryExtensions

    Defines a collection of extensions for dictionaries.

    Inheritance
    System.Object
    DictionaryExtensions
    Namespace: MADE.Collections
    Assembly: MADE.Collections.dll
    Syntax
    public static class DictionaryExtensions : object

    Methods

    | Improve this Doc View Source

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

    Adds or updates a value within a dictionary.

    Declaration
    public static void AddOrUpdate<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary

    The dictionary to update.

    TKey key

    The key of the value to add or update.

    TValue value

    The value to add or update.

    Type Parameters
    Name Description
    TKey

    The type of key item within the dictionary.

    TValue

    The type of value item within the dictionary.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The dictionary or key is null.

    | Improve this Doc View Source

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

    Gets a value from a dictionary by the specified key, or returns a default value.

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

    The dictionary to get a value from.

    TKey key

    The key to get a value for.

    TValue defaultValue

    The default value to return if not exists. Default, null.

    Returns
    Type Description
    TValue

    The value if it exists for the key; otherwise, null.

    Type Parameters
    Name Description
    TKey

    The type of key item within the dictionary.

    TValue

    The type of value item within the dictionary.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright (c) MADE Apps