如何在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 methodsParse
orTryParse
. Read about them:
http://msdn.microsoft.com/en-us/library/system.string.aspx[^].—SA