Pass a string from C# to a C++ DLL in .NET (and get a pointer to the string's chars)

/ Published in: C#
Save to your folder(s)

Specifically, this code enables you to pass a string from C# into C++ managed code and then get a C++ pointer to the string's chars.

[Marshal.StringToHGlobalAnsi Method]( from MSDN.

Good [information about native vs. managed types](

Related [forum post](

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.