Open sandboxFocus

Method TryGetProperty

TryGetProperty<T>(string, out T)

Gets the value of a named property for the current UnknownObjectAccessor.

Declaration
public bool TryGetProperty<T>(string name, out T value)
Parameters
Type Name Description
string name

Property name.

T value

Returns the property value if a property named name exists and its value can be cast to T, otherwise default.

Returns
Type Description
bool

true if the property value if a property named name exists and its value can be cast to T, otherwise false.

Type Parameters
Name Description
T

Type of the property value.

TryGetProperty<T>(object, string, out T)

Gets the value of a named property for an arbitrary object.

Declaration
public static bool TryGetProperty<T>(object instance, string name, out T value)
Parameters
Type Name Description
object instance

The object whose property has to be returned.

string name

Property name.

T value

Returns the property value if a property named name exists and its value can be cast to T, otherwise default.

Returns
Type Description
bool

true if the property value if a property named name exists and its value can be cast to T, otherwise false.

Type Parameters
Name Description
T

Type of the property value.