is
 IntPtr ptr =
Marshal.UnsafeAddrOfPinnedArrayElement((Array)handle.Target,0);

equivalent to:
  IntPtr ptr = handle.AddrOfPinnedObject();

or are there differences? I guess no.

Thomas




> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> On Behalf Of Rama Krishna
> Sent: Wednesday, May 29, 2002 17:06
> To: [EMAIL PROTECTED]
> Subject: Re: byte[] to Object
>                 struct MyMessage
>                 {
>                         int x;
>                         int y;
>                         int z;
>                         int u;
>                 }
>                         byte[] b = new byte[16];
>                         b[4] = 9;
>
>                         GCHandle handle = GCHandle.Alloc(b,
> GCHandleType.Pinned);
>                         IntPtr ptr =
> Marshal.UnsafeAddrOfPinnedArrayElement((Array)handle.Target, 0);
>
>                         MyMessage rc =
> (MyMessage)Marshal.PtrToStructure(ptr, typeof(MyMessage));
>
>                         handle.Free();
>                 }

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to