From http://www.haiders.net/post/Dictionary-Lookup-avoiding-KeyNotFound-Exception.aspx

Namespace: VVVV.Utils.Collections
Assembly: VVVV.Utils (in VVVV.Utils.dll) Version: 1.0.4694.10871

Syntax

C#
public static TValue ValueOrDefault<TKey, TValue>(
	this Dictionary<TKey, TValue> dictionary,
	TKey key
)

Parameters

dictionary
Type: System.Collections.Generic..::..Dictionary<(Of <(<'TKey, TValue>)>)>

[Missing <param name="dictionary"/> documentation for "M:VVVV.Utils.Collections.DictionaryExtensions.ValueOrDefault``2(System.Collections.Generic.Dictionary{``0,``1},``0)"]

key
Type: TKey
The key to look up.

Type Parameters

TKey

[Missing <typeparam name="TKey"/> documentation for "M:VVVV.Utils.Collections.DictionaryExtensions.ValueOrDefault``2(System.Collections.Generic.Dictionary{``0,``1},``0)"]

TValue

[Missing <typeparam name="TValue"/> documentation for "M:VVVV.Utils.Collections.DictionaryExtensions.ValueOrDefault``2(System.Collections.Generic.Dictionary{``0,``1},``0)"]

Return Value

The value associated with the key or default(TValue) of key not found.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Dictionary<(Of <(<'TKey, TValue>)>)>. When you use instance method syntax to call this method, omit the first parameter. For more information, see or .

See Also