Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
代码:
decimal pgr = decimal.Parse("$ 499.00");
我收到错误消息
System.FormatException:输入字符串的格式不正确。
如何将值解析为十进制?
decimal d = decimal.Parse("$499.00", NumberStyles.Currency);
尝试先删除字符串,
decimal pgr = decimal.Parse("$ 499.00".Replace("$", "").Replace(" ", ""));
.Replace(" ", "")在代码中添加以删除尾随、前导或中间的所有空格。
.Replace(" ", "")