Feature.GetValue

GetValue<T>(string)

Gets the value of an attribute.

public T GetValue<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. If the layer does not require its features to have values for all attributes defined for the layer, this method may fail with InvalidOperationException when a missing value is requested. When working with such layers, consider using GetValueOrDefault.

See Also


GetValue(string)

Gets the value of an attribute.

public object GetValue(string attributeName)
ParameterTypeDescription
attributeNameStringName 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.

Remarks

If the layer does not require its features to have values for all attributes defined for the layer, this method may fail with InvalidOperationException when a missing value is requested. When working with such layers, consider using GetValueOrDefault.

See Also