如题

解决方案 »

  1.   

    sizeof只能用于不安全的上下文中,请问还有没有其他办法?
      

  2.   

    你可以测试下就知道了,通过 byte[].length来取得长度
      

  3.   

    我是要在流中读取各种数据类型的数据到byte[]中,所以要预先知道各种数据类型的宽度好创建缓冲区.
      

  4.   

    这件事还得手动。我以前是这样做的:
    typedef struct
    {
    UInt32               attachmentindex;
    UInt16               attachmentcoding;
    UInt8                attachmentnext;
    UInt8                attachmentnums;
    }
    作1个对应的int数组
    int []intLength = {4,2,1,1}; 得到总长度只要用for循环把intLength加起来。改起来也简单。------------------------------------
    四十年来家国,三千里地山河,凤阁龙楼连霄汉,玉树琼枝作烟箩。几曾识干戈?
      

  5.   

    int intlong = (int)myFileStream.Length;
    byte[] bingbyte= new Byte[intlong];
      

  6.   

    int testObj = 99;
    System.Runtime.InteropServices.Marshal.SizeOf(testObj);