IPersistableObjectGetPropertyOrDefaultT Method

Gets the specified property if it exists in the inner storage and has a compatibly type with T; otherwise, returns defaultValue.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
T GetPropertyOrDefault<T>(
	string propertyName,
	T defaultValue = null
)

Parameters

propertyName  String
The name of the property to get.
defaultValue  T  (Optional)
The default value to return if property does not exist or has an incompatible type with T. This parameter is optional.
Default value: if T is a reference type; otherwise, the bitwise zero value of T.

Type Parameters

T
Type of the property to return.

Return Value

T
The found property value or defaultValue if propertyName was not found in this IPersistableObject.

Exceptions

InvalidOperationExceptionCannot get the property.

See Also