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.
我有一个绑定到货币数据字段的文本框。所以它会在文本的开头添加 '$' 或 ($xx.xx) 如果它是负数。如何从文本框中获取普通的双精度(xx.xx)而不是所有内容($xx.xx)?
确保在调用 double.Parse 时设置了正确的 NumberStyles 标志。
显然,您将使用下面的示例,但将文字字符串替换为对 TextBox 中文本的引用。
double d = double.Parse ("$10.10", NumberStyles.Currency);