IntPrt 的数据类型转为Byet[]   和Stream 都可以大家帮帮小弟。。急。。

解决方案 »

  1.   

    IntPtr是指针类型,跟Int32兼容.不知道你要转成那些干啥,先强制转化成int再看吧
      

  2.   


         IntPtr P=....;
         String S=System.Runtime.InteropServices.Marshal.PtrToStringAuto(P); 
           
      

  3.   

    知道指针指向类型的话使用Marshal.PtrToStructure(IntPtr,Type) 返回值是Object 转换成已知类型就行
      

  4.   

    先工程属性里设置允许不安全代码
    然后unsafe
    {
        int x = 'a';
        int *xp = &x;
        (*xp)++;
        IntPtr P = new IntPtr(xp);
        String S = System.Runtime.InteropServices.Marshal.PtrToStringAuto(P); 
        MessageBox.Show(S); // 显示 b
    }
      

  5.   

                    float[] NormalPointer = new float[2];
                    System.IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(NormalPointer, 0);
                    Byte[] rect = (Byte[])Marshal.PtrToStructure(pointer, typeof(Byte[]));                报这样的错:     没有为该对象定义无参数的构造函数