0

I have a numerical value in a string: 12.50000

When i want to convert that string to decimal using Convert.ToDecimal() it deletes the period and it becomes 1250000.

Is there a way to stop this? Because the final value is supposed to be 12.5, not 1250000.

FranciscoFJM
  • 119
  • 1
  • 10

1 Answers1

0
private void Test()
{
    var str = "12.50000";
    var y = decimal.TryParse(str, out var x);
    Debug.WriteLine(x);
}

why not using decimal.TryParse ?

goldii
  • 242
  • 2
  • 18
  • 1
    That will still fail for the OP (while possibly working for you), for the same reason: the current applicable Culture – Hans Kesting May 29 '20 at 12:30
  • @HansKesting. you are right. And we are developers , so we should consider all posiblities that we should. – goldii May 29 '20 at 15:38