Click or drag to resize

PropertyStoreTrySetT Method

Set the value for the specified property key, removing the value from the dictionary if it is the default value of T.

Namespace:  Eto
Assembly:  Eto (in Eto.dll) Version: 2.5.3-dev
Syntax
public bool TrySet<T>(
	Object key,
	T value,
	T defaultValue = null
)

Parameters

key
Type: SystemObject
Key of the property to set.
value
Type: T
Value for the property.
defaultValue (Optional)
Type: T
Value of the property when it should be removed from the dictionary. This should match what is passed to GetT(Object, T) when getting the value.

Type Parameters

T
The type of the property to set.

Return Value

Type: Boolean
true if the value was changed, false otherwise.
Remarks
This can be used as an optimized way to set the value in the dictionary as if the value set equal to the default value. (e.g. null for reference types, false for bool, 0 for int, etc), then it will be removed from the dictionary instead of just set to the value, reducing memory usage.
See Also