KGy SOFT

ObservableObjectBaseGetT Method (T, String)

KGy SOFT Core Libraries Help
Gets the value of a property or defaultValue if no value is stored for it. No new value will be stored if the property does not exist. If the default initial value is too complex and should not be evaluated every time when the property is get, or to throw an exception for an uninitialized property use the other Get overload.
For an example, see the Remarks section of the ObservableObjectBase class.

Namespace:  KGySoft.ComponentModel
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0
Syntax

protected T Get<T>(
	T defaultValue = null,
	string propertyName = null
)

Parameters

defaultValue (Optional)
Type: T
The value to return if property does not exist. This parameter is optional.
Default value: The default value of T type.
propertyName (Optional)
Type: SystemString
The name of the property to get. This parameter is optional.
Default value: The name of the caller member.

Type Parameters

T
The type of the property.

Return Value

Type: T
The value of the property, or the specified defaultValue.
Exceptions

ExceptionCondition
ArgumentNullExceptionpropertyName is .
InvalidOperationExceptionpropertyName cannot be get.
-or-
CanGetProperty is not overridden and propertyName is not an actual instance property in this instance.
See Also

Reference