开发者

How do I pass a char and a char* from C# to C++/CLI?

开发者 https://www.devze.com 2023-04-05 22:51 出处:网络
The title contains all. How do I pass a char and char* fro开发者_开发百科m C# to C++/CLI. Here is my cpp function declaration:

The title contains all. How do I pass a char and char* fro开发者_开发百科m C# to C++/CLI. Here is my cpp function declaration:

int ForexCpp::FXCrossDate(
             char usdTypeOfPeriods,
             char *holidayFile,
             TDate%         result);  /* (O) Resulting FX cross date */

In C#, char and char * are exposed as sByte and sByte*...


Since you have chosen to use C++/CLI rather than P/invoke the natural way to handle this is to pass a .net string rather than a char*.


Have you done any research on this yet? The internet is full of this type of stuff. Anyways, this page on MSDN lists various ways to convert between string types:

http://msdn.microsoft.com/en-us/library/ms235631.aspx

The one you want is at the bottom of the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消