user1317277
user1317277

Reputation: 113

Get C# String from "char*" returned from C++ library method?

I have a C++ library that I use in my C# application. One of the methods in the C++ library returns a char *. How can I convert that char * into a string in my C# application?

Apparently in my C# application, the data type returned in this method is of type sbyte *.

Upvotes: 2

Views: 679

Answers (1)

Thomas Levesque
Thomas Levesque

Reputation: 292385

String has a constructor that takes a char*:

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

And another one that takes a sbyte*:

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

Upvotes: 4

Related Questions