Sorry in advance for the triviality of this question (as I know it is related to the C# language structure) but I've been googling like crazy and couldn't find an answer.. so here it goes:
When I retrieve economic indicators' data through the .NET Real-time data API, this data comes in as object type. However, I would like to perform simple mathematical operations on this data (substractions, multiplications..) but keep getting the error "Operator '-' cannot be applied to operands of type 'object' and 'object'" when I try to.
I tried converting the obtained data from object type to other types allowing calculations (like int, float etc..) but the console simply stops responding when that part of the code comes up: I get no result, just an eternal wait.
Could you help me ??
Thanks for your time!
When you get FieldValue object you can use ToDecimal or ToDouble methods to convert the value to System.Decimal or System.Double. If field value may be null use ToNullableDecimal or ToNullableDouble to convert the value to System.Decimal? or System.Double?. E.g. fieldUpdate.Value.ToDouble()