Skip to content

M_CodeJam_Collections_DictionaryExtensions_GetValueOrDefault__2_3

Andrew Koryavchenko edited this page Jun 17, 2018 · 7 revisions

DictionaryExtensions.GetValueOrDefault(TKey, TValue) Method (Dictionary(TKey, TValue), TKey)

Returns value associated with key, or default(TValue) if key does not exists in dictionary

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

Syntax

C#

public static TValue GetValueOrDefault<TKey, TValue>(
	this Dictionary<TKey, TValue> dictionary,
	TKey key
)

VB

<ExtensionAttribute>
Public Shared Function GetValueOrDefault(Of TKey, TValue) ( 
	dictionary As Dictionary(Of TKey, TValue),
	key As TKey
) As TValue

F#

[<ExtensionAttribute>]
static member GetValueOrDefault : 
        dictionary : Dictionary<'TKey, 'TValue> * 
        key : 'TKey -> 'TValue 

Parameters

 

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

Type Parameters

 

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

Return Value

Type: TValue
Value, associated with the key, or default value if key does not exists in dictionary

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

DictionaryExtensions Class
GetValueOrDefault Overload
CodeJam.Collections Namespace

Clone this wiki locally