relying on inline isn't reliable. Instead, you can create
a pinning handle (see
System.Runtime.InteropServices.GCHandle) but you have to
Free it explicitly as soon as possible.
>-----Original Message-----
>#include <vcclr.h>
>To keep our code a little "cleaner" I'd like to encapsulate the converting of System::Strings to char
pointers.
>I know putting the code in a function will not work because when the __pin goes out of scope, the string is no
longer locked in memory.
>Would making the function inline work (keep the __pin in
scope)?
>Is there anywhat to test this?
>
>Thanks, Steve W
>
>inline const __wchar_t * SysStringToLPCSTR(System::String
*String)
>{
> const __wchar_t __pin * PinnedStr;
[quoted text clipped - 5 lines]
>}
>.