Κοινή χρήση μέσω


AdditionalPropertiesDictionary.TryGetValue Method

Definition

Overloads

TryGetValue(String, Object)
TryGetValue<T>(String, T)

Attempts to extract a typed value from the dictionary.

TryGetValue(String, Object)

public:
 virtual bool TryGetValue(System::String ^ key, [Runtime::InteropServices::Out] System::Object ^ % value);
public bool TryGetValue (string key, out object? value);
abstract member TryGetValue : string * obj -> bool
override this.TryGetValue : string * obj -> bool
Public Function TryGetValue (key As String, ByRef value As Object) As Boolean

Parameters

key
String
value
Object

Returns

Applies to

TryGetValue<T>(String, T)

Attempts to extract a typed value from the dictionary.

public:
generic <typename T>
 bool TryGetValue(System::String ^ key, [Runtime::InteropServices::Out] T % value);
public bool TryGetValue<T> (string key, out T? value);
member this.TryGetValue : string * 'T -> bool
Public Function TryGetValue(Of T) (key As String, ByRef value As T) As Boolean

Type Parameters

T

Specifies the type of the value to be retrieved.

Parameters

key
String

The key to locate.

value
T

The value retrieved from the dictionary, if found and successfully converted to the requested type; otherwise, the default value of T.

Returns

true if a non-null value was found for key in the dictionary and converted to the requested type; otherwise, false.

Remarks

If a non-null is found for the key in the dictionary, but the value is not of the requested type but is an IConvertible object, the method will attempt to convert the object to the requested type.

Applies to