如何将textbox.text中内容以16进制保存在byte[]数组中.
 例如:
textbox1.text="10";
byte[] mm=new byte[64];
mm[0]=0x0a  //textbox1.text中内容以16进制保存在mm[0]中;

解决方案 »

  1.   

    byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str );
      

  2.   

    string mm="0ac2b0"
    char[] ch=new char[4];
    怎么得到:
    mm[0]=0x0a;
    mm[1]=0xc2x;
    mm[2]=0xb0;
    各位大哥大姐帮下忙,在线等待,急切盼望中ing;
      

  3.   

    先转换成数字.
                string _Text ="10";
                long _Long = 0;            byte[] mm = new byte[64]; 
                if (long.TryParse(_Text, out _Long))
                {
                    Array.Copy(BitConverter.GetBytes(_Long), mm, 8);
                }
    这样??? 
      

  4.   

        string mm = "0ac2b0";            byte[] _Value =new byte[mm.Length/2];            for (int i = 0; i != _Value.Length; i++)
                {
                    _Value[i] = Convert.ToByte(mm.Substring(i * 2, 2), 16);
                }            ...
      

  5.   

    string str = "0ac2b0";
                byte[] mm=new byte[str.Length/2];
                for (int i = 0; i < mm.Length; i++)
                {
                    mm[i] = Convert.ToByte(str.Substring(i * 2, 2), 16);
                }
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
      

  6.   

    textBox1.Text = _Value[0].ToString ();
    得到的_Value[0]=10;我说的是_Value[0]=0x0a.在麻烦看下,拜托
      

  7.   

    textBox1.Text = _Value[0].ToString ("X02"); 
    0x0a==10.........
      

  8.   

    哈哈 thanyou    (ZGKE谢谢你)
    问题解决了
     揭贴了