Table of Contents

Method SafeGet

Namespace
Anvil.API
Assembly
NWN.Anvil.dll

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

Safely gets a value from a dictionary, or the default if the key does not exist.

public static TValue? SafeGet<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)

Parameters

dictionary IDictionary<TKey, TValue>

The dictionary to query.

key TKey

The key to look up.

Returns

TValue

The value for the key if present; otherwise the default value for TValue.

Type Parameters

TKey

The dictionary key type.

TValue

The dictionary value type.