Jon, sorry, there was just a typing error... here's the right code:
... public unsafe void FillMyStruct(string s) { // // convert the given string into a byte array // byte[] data = Encoding.UTF8.GetBytes(s); // // create another byte array for storing // a new instance of MyStruct // byte[] buffer = new byte[ sizeof(int) // Size of MyStruct.Id + data.Length]; // Length of MyStruct.Data // // fill the buffer // fixed (byte* pBuffer = buffer, pData data) { MyStruct* pMyStruct = (MyStruct*) pBuffer; pMyStruct->Id = 100; pMyStruct->Data = pBuffer + sizeof(int); // here should be // pBuffer instead // of pData!!! UnsafeCopy( pData, 0, // source buffer pMyStruct->Data, 0, // destination buffer // this points now to // pBuffer + 4 data.Length); // number of bytes to copy } } In the code above there is no overlapping and it works fine (I've tried it). j3d. > > > _______________________________________________ > Mono-list maillist - Mono-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-list > ---------------------------------------- Giuseppe Greco ::agamura:: call giuseppe.greco via Skype phone: +41 (0)91 604 67 65 mobile: +41 (0)79 590 33 06 email: [EMAIL PROTECTED] web: www.agamura.com ---------------------------------------- _______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list