Feature.GetValueOrDefault

GetValueOrDefault<T>(string)

Gets the value of an attribute, or DefaultValue if the value is unset or null.

public T GetValueOrDefault<T>(string attributeName)
ParameterDescription
TDesired type for the value.
attributeNameName of the attribute.

Return Value

Value of the attribute.

Exceptions

exceptioncondition
ArgumentNullExceptionThe attribute name is null.
ArgumentExceptionThe attribute with this name does not exist in this layer.
InvalidOperationExceptionThe attribute is not locked.
InvalidOperationExceptionThe value of this attribute is not set for this feature.
InvalidCastExceptionThe requested type does not implement IConvertible.
InvalidCastExceptionValue of the attribute is null, but the requested type is a value type.
FormatExceptionConversion failed because the value is in incorrect format.
OverflowExceptionConversion failed because of overflow.

Remarks

This method converts the value automatically to the type requested in the generic type parameter.

See Also


GetValueOrDefault(string, object)

Gets the value of an attribute, or DefaultValue if the value is unset or null.

public object GetValueOrDefault(string attributeName, object defaultValue = null)
ParameterTypeDescription
attributeNameStringName of the attribute.
defaultValueObjectThe value to return if the attribute value is missing. Default value is null.

Return Value

Value of the attribute.

Exceptions

exceptioncondition
ArgumentNullExceptionThe attribute name is null.
ArgumentExceptionThe attribute with this name does not exist in this layer.
InvalidOperationExceptionThe attribute is not locked.
InvalidOperationExceptionThe value of this attribute is not set for this feature.

See Also


GetValueOrDefault<T>(string, object)

Gets the value of an attribute, or DefaultValue if the value is unset or null.

public T GetValueOrDefault<T>(string attributeName, object defaultValue)
ParameterDescription
TDesired type for the value.
attributeNameName of the attribute.
defaultValueThe value to return if the attribute value is missing.

Return Value

Value of the attribute.

Exceptions

exceptioncondition
ArgumentNullExceptionThe attribute name is null.
ArgumentExceptionThe attribute with this name does not exist in this layer.
InvalidOperationExceptionThe attribute is not locked.
InvalidOperationExceptionThe value of this attribute is not set for this feature.
InvalidCastExceptionThe requested type does not implement IConvertible.
InvalidCastExceptionValue of the attribute is null, but the requested type is a value type.
FormatExceptionConversion failed because the value is in incorrect format.
OverflowExceptionConversion failed because of overflow.

Remarks

This method converts the value automatically to the type requested in the generic type parameter.

See Also