Skip to content

IDictionaryExtensions

Namespace: SideXP.Core

public static class IDictionaryExtensions

Extension functions for IDictionary2` instances.

Methods

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

public static void GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue> dictionary, TKey key, out TValue value)

Gets a value in a dictionary, or add a new entry if it doesn't exist.

Type parameters

  • TKey: The type of the dictionary's key.
  • TValue: The type of the dictionary's value.

Parameters

  • dictionary: The dictionary's value.
  • key: The dictionary's key.
  • value: Outputs the found (or added) value.

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

public static void GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue> dictionary, TKey key, out TValue value, TValue defaultValue)

Gets a value in a dictionary, or add a new entry if it doesn't exist.

Type parameters

  • TKey: The type of the dictionary's key.
  • TValue: The type of the dictionary's value.

Parameters

  • dictionary: The dictionary's value.
  • key: The dictionary's key.
  • value: Outputs the found (or added) value.
  • defaultValue: The default value to set if the key doesn't exist in the dictionary.