if ((double)_feature.get_Value(_feature.Fields.FindField("MYFIELD")) > 8.33)
Public Shared Function DatabaseToDouble(ByVal value As Object, ByVal defaultValue As Double) As Double If value Is DBNull.Value Then Return defaultValue Else Return Convert.ToDouble(value) End If End Function
Public Shared Function DatabaseToDouble(ByVal value As Object) As Double If value Is DBNull.Value Then Return 0 Else Return Convert.ToDouble(value) End If End Function
ToString will fail if the object is dbnull value. Happens all the time, you have to check for that every time, it is a real pain. If the type returned was a AO type, I would write an extension to check for that but I hesitate on writing extensions for type object.
cannot perform the operator on "object" and "double"
What do you get when you do this?_feature.get_Value(_feature.Fields.FindField("MYFIELD")).ToString()
_feature.get_Value(_feature.Fields.FindField("MYFIELD")).ToString()
If the value in the field is null, you will not be able to cast it to double. When there is a null value in a field, .net returns a dbnull.value which cannot be cast to a double even if the field type is double. Perhaps this is the problem.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.