Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top