[英]Get C# String from “char*” returned from C++ library method?
I have a C++ library that I use in my C# application. 我有一个在C#应用程序中使用的C ++库。 One of the methods in the C++ library returns a
char *
. C ++库中的一种方法返回
char *
。 How can I convert that char *
into a string in my C# application? 如何在我的C#应用程序中将
char *
转换为字符串?
Apparently in my C# application, the data type returned in this method is of type sbyte *
. 显然,在我的C#应用程序中,此方法返回的数据类型为
sbyte *
。
String
has a constructor that takes a char*
: String
具有一个采用char*
的构造函数 :
char* x = ...
string s = new string(x);
And another one that takes a sbyte*
: 另一个需要一个
sbyte*
:
sbyte* x = ...
string s = new string(x);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.