PubSendBuffer改成byte类型
用序列化

解决方案 »

  1.   

    必须得把PubSendBuffer改成byte类型吗?
    因为我定义的数组PubSendBuffer是用来接受Socket数据的。能不能不改?还有其他的方法吗?或者有类似的函数?
      

  2.   

    C++中memcpy原型函数是用到了指针。 
    void *memcpy(void *dest, void *src, unsigned int count);
    可是我要自己写函数,不是也要用到了指针吗?
    能给点提示吗?怎么把结构体的地址空间内容,复制count个字节到数组地址?
      

  3.   

    通用的肯定不行的,C++里的struct和C#肯定不一样。
    自己转吧,一个int转成4个byte等等,到C#再按格式转回来。
      

  4.   

    类似于这样的实现?
    public char[] ToArray()
    {
    List<char> lPutChar = new List<char>();
    lPutChar.Add((char)nTranCode);
    lPutChar.Add((char)nOperMode);
    lPutChar.Add((char)nAdditionalFlag);
    foreach(char c1 in nPackageLength.ToString())
    {
    lPutChar.Add(c);
    }
    foreach(char c2 in cOperCode)
    {
    lPutChar.Add(c2);
    }
    return lPutChar.ToArray();
    }
    还有更好方法的函数吗?请举例参考!