1

I have an expression which contains numbers that are separated by , or ., i.e a number in the expression can be 2,3 or 2.3. I get values to generate the expression from the database where the values are stored in one of the above format. I have an additional textbox in the Calculate page where the user enters a value during runtime.

If the value are in the format 2.3 the value is computed by DataTable.Compute and the result is in the comma separated format. How do I make DataTable.Compute to evaluate any string?

I have added but still it doesn't work. I get SyntaxErrorException

 Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");

EDIT

Replacing the , in the expression with . can solve the problem. But when the result is displayed in the comma separated format why doesn't it accept input in the same format?

Vini
  • 1,978
  • 8
  • 40
  • 82
  • are the numbers alone? i mean you can convert `,` to `.` if they are not inside expression so `,` as decimal seperator will not be confused with other things inside expression and you can safely change `,` to `.` – M.kazem Akhgary Nov 03 '15 at 10:35
  • that was a real straightforward thing that i too thought of, to replace `,` with `.`. But I think there should be a way using this `CultureInfo` to evaluate the expression. I am not sure. – Vini Nov 03 '15 at 10:37
  • And the interesting part is that I get the result in the comma separated format. :) – Vini Nov 03 '15 at 10:39

0 Answers0