ViewDataDictionary.TryGetValue Method

Attempts to retrieve the value that is associated with the specified key.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Public Function TryGetValue ( _
    key As String, _
    <OutAttribute> ByRef value As Object _
) As Boolean
public bool TryGetValue(
    string key,
    out Object value
)
public:
virtual bool TryGetValue(
    String^ key, 
    [OutAttribute] Object^% value
) sealed

Parameters

  • value
    Type: System.Object%
    When this method returns, the value that is associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Return Value

Type: System.Boolean
true if the collection contains an element with the specified key; otherwise, false.

Implements

IDictionary<TKey, TValue>.TryGetValue(TKey, TValue%)

Exceptions

Exception Condition
ArgumentNullException

key is null reference (Nothing in Visual Basic).

See Also

Reference

ViewDataDictionary Class

System.Web.Mvc Namespace