0

Code:

decimal pgr = decimal.Parse("$ 499.00");

I am getting the error message as

System.FormatException: Input string was not in a correct format.

How to parse a value to decimal?

Earth
  • 3,477
  • 6
  • 37
  • 78

2 Answers2

3
decimal d = decimal.Parse("$499.00", NumberStyles.Currency);
Abdullah Shoaib
  • 2,065
  • 2
  • 18
  • 26
0

try removing the string first,

decimal pgr = decimal.Parse("$ 499.00".Replace("$", "").Replace(" ", ""));

.Replace(" ", "") was added in the code to remove all spaces either trailing, leading or in between.

John Woo
  • 258,903
  • 69
  • 498
  • 492