从C ++库方法返回的“char *”中获取C#字符串?

时间:2012-05-28 22:58:39

标签: c# c++ visual-studio-2010 visual-c++

我有一个C ++库,我在C#应用程序中使用它。 C ++库中的一个方法返回char *。如何将char *转换为我的C#应用​​程序中的字符串?

显然在我的C#应用​​程序中,此方法返回的数据类型是sbyte *类型。

1 个答案:

答案 0 :(得分:4)

Stringa constructor that takes a char*

char* x = ...
string s = new string(x);

another one that takes a sbyte*

sbyte* x = ...
string s = new string(x);