Skip to content

Properties.Set Method ​

Overloads ​

NameDescription
Set<T>(String, T)Sets the value of a single valued property with the specified key.
Set<T>(String, T, T)Sets the value of a single valued property with the specified key. Uses a field to cache the value for better performance.
Set<T>(String, T, T?)Sets the value of a single valued property with the specified key. Uses a field to cache the value for better performance.

Set<T>(String, T) ​

Sets the value of a single valued property with the specified key.

c#
public void Set<T>(string key, T value);

View source

Type Parameters ​

NameDescription
TThe type of the property.

Parameters ​

NameTypeDescription
keyStringThe key of the property.
valueTThe value of the property.

Set<T>(String, T, T) ​

Sets the value of a single valued property with the specified key. Uses a field to cache the value for better performance.

c#
public void Set<T>(string key, T value, out T? cached)
   where T : class;

View source

Type Parameters ​

NameDescription
TThe type of the property.

Parameters ​

NameTypeDescription
keyStringThe key of the property.
valueTThe value of the property.
cachedTThe key of the property.

Remarks ​

Properties are stored in a dictionary which might not have enough performance in some situations. Use this overload to get higher performance as the value will be stored in the field if it exists. Make sure to use GetOrThrow<T>(String, T) to retrieve the cached field.

Set<T>(String, T, T?) ​

Sets the value of a single valued property with the specified key. Uses a field to cache the value for better performance.

c#
public void Set<T>(string key, T value, out T?? cached)
   where T : struct;

View source

Type Parameters ​

NameDescription
TThe type of the property.

Parameters ​

NameTypeDescription
keyStringThe key of the property.
valueTThe value of the property.
cachedT?The key of the property.

Remarks ​

Properties are stored in a dictionary which might not have enough performance in some situations. Use this overload to get higher performance as the value will be stored in the field if it exists. Make sure to use GetOrThrow<T>(String, T) to retrieve the cached field.