如何在C#和VS 2010中将ascii转换为整数或双精度?
问题描述:
我正在研究从串口转换数据的项目。我想将它从ascii转换为整数或双精度。我试过函数
Hi, I'm working project about convert data receive from serial port. I want convert it from ascii to integer or double. I tried with function
Double.TryParse(txtkq.Text, out data_re);
用txtkq.Text是从串口接收的文本框显示数据。但它不起作用。那么谁能帮助我呢?我使用C#和visual studio 2010.
谢谢!
with txtkq.Text is textbox display data receive from serial. but it's not working. so who can help me, please? I use C# and visual studio 2010.
Thanks!
答
这应该有用。
你能提供一份文本样本吗?
使用调试器查看实际值是多少。
使用RegularExpression确保你只有你想要的部分。
That should work.
Can you provide a sample of the text?
Use the debugger to see what the actual value is.
Use a RegularExpression to ensure that you only have the parts you want.