I have datable with values, most of them are values with decimals. I`m converting comma to dot and then sum in one variable as below. The problem is that method is incorrect. For example value:
12,1235 will turn in to 12.1235 ( it will read as 12 thousands instead of twelve with decimal ,1235 ) so my total sum is incorrect.
For each row in datable:
CurrentRow(“values”).ToString.Replace(“,”,“.”)
Sum=Sum+Cdbl(CurrentRow(“values”)
dtData.AsEnumerable.Sum(Function (x) Double.Parse(x("values").toString.Trim, new System.Globalization.CultureInfo("de-DE")))
we would recommend to implement it via this Culture approach instead of String manipulations as we do have a controlled fail, when the format is not as expected. Also it avoids side effects as a valid string of 1.234,56 would not be changed to 1.234.56