c# 如何将int型 转 byte[]?

解决方案 »

  1.   

    byte[] send_data = new byte[4] { 0x05, 0x30, 0x30, 0x57 };
    int g=1;
    send_data[1] = BitConverter.GetBytes(g);
    这样写报错,为什么,有别的方法吗
      

  2.   

    。send_data = BitConverter.GetBytes(g);
    GetBytes得到是数组啊,老大 
      

  3.   

    按照lz思路
    int num=1;
    byte[] data=new byte[]{(byte)num};
      

  4.   

    byte[] send_data  为什么还要转成byte呢,它本身就是个byte【】,可以直接发送过去的。