-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_CollectionExtensions_DefaultIfEmpty__2_1
Andrew Koryavchenko edited this page Jun 17, 2018
·
1 revision
CollectionExtensions.DefaultIfEmpty(TKey, TValue) Method (Dictionary(TKey, TValue), TKey, TValue, IEqualityComparer(TKey))
Returns a new dictionary with default value if the dictionary is empty.
Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static Dictionary<TKey, TValue> DefaultIfEmpty<TKey, TValue>(
this Dictionary<TKey, TValue> dictionary,
TKey defaultKey,
TValue defaultValue,
IEqualityComparer<TKey> comparer
)
VB
<ExtensionAttribute>
Public Shared Function DefaultIfEmpty(Of TKey, TValue) (
dictionary As Dictionary(Of TKey, TValue),
defaultKey As TKey,
defaultValue As TValue,
comparer As IEqualityComparer(Of TKey)
) As Dictionary(Of TKey, TValue)
F#
[<ExtensionAttribute>]
static member DefaultIfEmpty :
dictionary : Dictionary<'TKey, 'TValue> *
defaultKey : 'TKey *
defaultValue : 'TValue *
comparer : IEqualityComparer<'TKey> -> Dictionary<'TKey, 'TValue>
- dictionary
- Type: System.Collections.Generic.Dictionary(TKey, TValue)
The dictionary. - defaultKey
- Type: TKey
The default key. - defaultValue
- Type: TValue
The default value. - comparer
- Type: System.Collections.Generic.IEqualityComparer(TKey)
The comparer.
- TKey
- The type of the key.
- TValue
- The type of the value.
Type: Dictionary(TKey, TValue)
A new dictionary with default key and value if the dictionary is empty.
In Visual Basic and C#, you can call this method as an instance method on any object of type Dictionary(TKey, TValue). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
CollectionExtensions Class
DefaultIfEmpty Overload
CodeJam.Collections Namespace