[Mono-list] Fast Passing Strings to Interop without Marshaling
jonpryor at vt.edu
Mon Nov 3 13:00:52 EST 2008
On Mon, 2008-11-03 at 09:41 -0800, Bradford Stephens wrote:
> I believe you still have to use the Marshaling in order to get an IntPtr.
Yes, but marshaling an IntPtr doesn't require copying the entire buffer.
Marshaling as a System.String *does* require copying the entire buffer.
4 bytes is clearly less than 100kB+. :-)
So unless you really need a System.String, you could instead use IntPtr
and use the System.Runtime.InteropServices.Marshal methods to interact
with the unmanaged string, or you could use unsafe code and cast the
IntPtr to a byte* for memory manipulation...
More information about the Mono-list