Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Marshall c#字符串到c++; 我想知道如何将C++字符串转换成一个本地C++ car *。我试过了,但似乎什么都没用。谢谢。_C#_Marshalling - Fatal编程技术网

Marshall c#字符串到c++; 我想知道如何将C++字符串转换成一个本地C++ car *。我试过了,但似乎什么都没用。谢谢。

Marshall c#字符串到c++; 我想知道如何将C++字符串转换成一个本地C++ car *。我试过了,但似乎什么都没用。谢谢。,c#,marshalling,C#,Marshalling,记住,C++ char实际上是一个字节,因此需要使用像之类的字节将它传递给字节[]。 string str; // Contains string to pass to C++ DLL byte[] bytes = Encoding.UTF8.GetBytes(str); MyFun(bytes); // Call the C++ function with the string 另请参阅以获取不同的透视图。可能的重复项通常不需要这样做-您通常应该能够将函数声明为使用System.String

记住,C++ char实际上是一个字节,因此需要使用像

之类的字节将它传递给字节[]。
string str; // Contains string to pass to C++ DLL
byte[] bytes = Encoding.UTF8.GetBytes(str);
MyFun(bytes); // Call the C++ function with the string

另请参阅以获取不同的透视图。

可能的重复项通常不需要这样做-您通常应该能够将函数声明为使用System.String参数。