Gets the value from the lookup, returning defaultValue if the value doesn't exist.

Namespace: DotNetNuke.Collections
Assembly: DotNetNuke (in DotNetNuke.dll)

Syntax

C#
public static T GetValueOrDefault<T>(
	this ILookup<string, string> lookup,
	string key,
	T defaultValue
)
Visual Basic
<ExtensionAttribute> 
Public Shared Function GetValueOrDefault(Of T) ( 
	lookup As ILookup(Of String, String),
	key As String,
	defaultValue As T
) As T

Parameters

lookup
Type: System.Linq..::..ILookup<(Of <(<'String, String>)>)>
The lookup.
key
Type: System..::..String
The key by which to get the value.
defaultValue
Type: T
The default value to return if the lookup doesn't have a value for the given key.

Type Parameters

T
The type of the value to retrieve

Return Value

A T instance.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ILookup<(Of <(<'String, String>)>)>. When you use instance method syntax to call this method, omit the first parameter. For more information, see [b8020aae-374d-46a9-bcb7-8cc2390b93b6] or [175ce3ff-9bbf-4e64-8421-faeb81a0bb51].

Exceptions

ExceptionCondition
System..::..InvalidCastException the value is null and T is a value type, or the value does not implement the IConvertible interface and no cast is defined from the value to T
System..::..ArgumentNullExceptionlookup is null
System..::..InvalidOperationExceptionlookup has multiple values for the given key

See Also