-
Notifications
You must be signed in to change notification settings - Fork 11
Common Dictionary
Ivan Kozhin edited this page Aug 24, 2020
·
4 revisions
TValue GetValueOrDefault<TKey, TValue>(
IDictionary<TKey, TValue> target,
TKey key,
TValue defaultValue)Tries to get the value by key. If the key is not presented in the dictionary it returns defaultValue.
TValue AddOrUpdate<TKey, TValue>(
IDictionary<TKey, TValue> target,
TKey key,
Func<TKey, TValue, TValue> updateFunc,
TValue defaultValue)Adds a key/value pair to the IDictionary{TKey,TValue} if the key does not already exist, or updates a key/value pair in the IDictionary{TKey,TValue} if the key already exists. The default value will be used if the key is missed to the IDictionary{TKey,TValue}.
string GetValueOrDefault(NameValueCollection target, string key, string defaultValues)Tries to get the value in NameValueCollection. If a value with the specified key does not exist it will return defaultValues. It can be used for application settings.
string[] GetValuesOrDefault(NameValueCollection target, string key, string[] defaultValues)Tries to get the values in NameValueCollection. If a value with the specified key does not exist it will return defaultValues. It can be used for application settings.