[英]string in C# and String^ in C++/CLI… How to pass “null”?
[英]C# string passed to C++ CLI
没看到我在S / O上寻找的东西。 我有一个需要将值传递给C ++ CLI应用程序(托管代码)的C#应用程序。 (我真的只需要通过STRING传递)
C#我有
double xCoordinate = 4820.85;
double yCoordinate = 9792.93;
string stringName = "My string stuff";
abc.Highlight(xCoordinate, yCoordinate, stringName);
在C ++ / CLI中我希望收到字符串(double似乎很好)
我读到了以下内容
C++ --> std::wstring
or in C++ --> extern "C" __declspec void GetString( char* buffer, int* bufferSize );
C# --> void GetString( StringBuilder buffer, ref int bufferSize );
也许
System::String^
const char *
? 所以我似乎只希望将C#中的字符串发送到C ++ / CLI,虽然它看起来很简单,但我没有接受过C ++的培训,找到Interop / marshalling的例子似乎并不那么简单。
如果您使用的是C ++ / CLI,则可以直接使用String
:
void Highlight(double xCoordinate, double yCoordinate, String^ name)
{
//...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.