Skip to content

Properties.GetOrAdd 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 GetOrAdd<T>(string key, Func<string, T> defaultCreator);

View source

Type Parameters ​

NameDescription
TThe type of the property.

Parameters ​

NameTypeDescription
keyStringThe key of the property.
defaultCreatorFunc<String, T>Function to create the value to return if the property does not exist.

Returns ​

T

The value of the property.