例 次の例では、マネージド String クラスの内容をアンマネージ メモリに変換し、完了したらアンマネージ メモリを破棄する方法を示します。 using namespace System; using namespace System::Runtime::InteropServices; #include <iostream> // for printf int main() { // Create a managed string. String^ managedString = "Hello unmanaged world (from the managed world)."; // Marshal the managed string to unmanaged memory. char* stringPointer = (char*) Marshal::StringToHGloba
![Marshal.StringToHGlobalAnsi(String) メソッド (System.Runtime.InteropServices)](https://cdn-ak-scissors.b.st-hatena.com/image/square/82e6564e92b1828f860a7d892b895a946b3eb2ea/height=288;version=1;width=512/https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fmedia%2Flogos%2Flogo-ms-social.png)