如何在C#中将字符串从文本框转换为十进制值?

如何在C#中将字符串从文本框转换为十进制值?

问题描述:

我想使用文本框中的转换值,然后将其转换为十进制值,以便可用于计算。

I want to use a conversion value from a textbox and then convert it into a decimal value so it is usable for calculations.

您没有转换 ,你解析字符串。使用其中一个字符串方法 Parse TryParse 。了解它们:

http://msdn.microsoft.com/ en-us / library / system.string.aspx [ ^ ]。



-SA
You do not "convert", you parse the string. Use one of the string methods Parse or TryParse. Read about them:
http://msdn.microsoft.com/en-us/library/system.string.aspx[^].

—SA