Skip to content

M_CodeJam_Collections_CollectionExtensions_EmptyIfNull__2_1

Andrew Koryavchenko edited this page Jun 17, 2018 · 1 revision

CollectionExtensions.EmptyIfNull(TKey, TValue) Method (Dictionary(TKey, TValue), IEqualityComparer(TKey))

Returns an empty instance of the dictionary for null values.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static Dictionary<TKey, TValue> EmptyIfNull<TKey, TValue>(
	this Dictionary<TKey, TValue> dictionary,
	IEqualityComparer<TKey> comparer
)

VB

<ExtensionAttribute>
Public Shared Function EmptyIfNull(Of TKey, TValue) ( 
	dictionary As Dictionary(Of TKey, TValue),
	comparer As IEqualityComparer(Of TKey)
) As Dictionary(Of TKey, TValue)

F#

[<ExtensionAttribute>]
static member EmptyIfNull : 
        dictionary : Dictionary<'TKey, 'TValue> * 
        comparer : IEqualityComparer<'TKey> -> Dictionary<'TKey, 'TValue> 

Parameters

 

dictionary
Type: System.Collections.Generic.Dictionary(TKey, TValue)
The dictionary.
comparer
Type: System.Collections.Generic.IEqualityComparer(TKey)
The comparer.

Type Parameters

 

TKey
The type of the key.
TValue
The type of the value.

Return Value

Type: Dictionary(TKey, TValue)
The dictionary or null if the dictionary is null.

Usage Note

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).

See Also

Reference

CollectionExtensions Class
EmptyIfNull Overload
CodeJam.Collections Namespace

Clone this wiki locally