大家好:   小弟用 SerialPort.ReadByte() 读取COM1 的一组ASCII字符.保存到 buff
(int [] buff = new int[8] )    内容为  buff = " 128.66 "  // ASCII 字符串    请问怎样将这个字符串转为 double 的 128.66 值呢? 谢谢!

解决方案 »

  1.   

    转换成  string ,然后转换成 double
      
    ————————————————————————————————————
    现在有的人要求越来越高!事情还是十画还没有一撇,就要完整源码!
    怎么办呢?
      

  2.   

    char[] buff = new char[] { '1','2', '8', '.', '6', '6' };
                string s = new string(buff);            double d = double.Parse(s);
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070212http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  3.   

    char[] buffer = new char[8];
    //SerialPort.ReadByte() int是4个字节并不是byte,ReadByte用char更好
    string str = new string(buffer);
    double d = double.Parse(str);
      

  4.   

    byte[] buff = new byte[8];
    //用byte[]这样处理
    double.Parse(Encoding.ASCII.GetString(buff));
      

  5.   

    SerialPort.ReadByte() 的返回值是 int 类型!我也不知为什么?
    按理应该是BYTE才对啊?!