1

I have a currency field inside a SharePoint List. When I retrieve that field the result type is "double". As it should be according to the documentation.

But we all learned that double is a bad choice when dealing with currency values. But how to deal with it in csom sharepoint? Currently I cast all currency-values to decimal before doing any operations:

decimal lotsofcash=(decimal)(double)listItem.Value;
lotsofcash+=124.56;
listItem.Value=lotsofcash;

Is there a smarter way to do this? Is there a better fieldtype?

0

I would think based on the answers in the stack overflow thread that using double as your datatype is a bad format only if you are doing multiple operations, because the accuracy of the cents will start to skew depending on the number of operations. The question becomes, are you doing a bunch of manipulation? If you are just doing a simple addition, double should be fine for your purposes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.