简体   繁体   English

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

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM