Skip to content

Properties.GetOrDefault Method ​

Definition ​

Gets the value of a single valued property with the specified key or returns a default value if the property does not exist.

c#
public T? GetOrDefault<T>(string key, T? @default = null);

View source

Type Parameters ​

NameDescription
TThe type of the property.

Parameters ​

NameTypeDescription
keyStringThe key of the property.
defaultTThe value to return if the property does not exist.

Returns ​

T

The value of the property.