473,226 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Re: Why is a "char *" method parameter being projected as a "sbyte *"?

Chip Gore wrote:
On Apr 10, 4:54 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
>On Thu, 10 Apr 2008 14:41:19 -0700, Chip Gore
<chip.g...@intersystems.comwrote:
>>[...]
And when I try and call this from "C-Sharp-Land", I'm being told
that my s1 and s2 are of type "sbyte *", and I'm not sure how to
get a C# "string" to be able to be passed in to my DEMO::DoStuff()
method.

Short, useless answer: in C#, the "char" type is Unicode, 2 bytes per
character. A C++ "char" is in fact the same as a C# "sbyte" (signed
byte).

What you really want to know is how to get .NET strings to play nice
with C++ strings ("char" arrays). Depending on what your C++ code
is doing, you either need to just use .NET strings (i.e. instances
of "String") in your managed C++ code, or you need to marshal
between the .NET String class and your C++ strings. Here's an MSDN
page that might be a good starting
point:http://msdn2.microsoft.com/en-us/library/bb384865.aspx

In this newsgroup, Ben, Willy, and maybe one or two others, might
have an answer to your question. But this is a perfect example of
the sort of question that is completely on-topic in the
microsoft.public.dotnet.framework.interop newsgroup. In that forum,
they are doing this sort of thing on a regular basis and you'll get
the best, most complete answers posting in that newsgroup.

Pete

Thanks for the feedback, I'll re-post the request in the interop
newsgroup
Actually, because you are using the C++/CLI compiler,
microsoft.public.dotnet.languages.vc is the most appropriate place to
discuss this.

To be useful from C# and other .NET languages, the member functions of your
ref class should accept parameters of type System::String^. The C++/CLI
compiler provides some pretty simple methods for getting the data as native
C++ characters if you need to, for example the PtrToStringChars function.
Jun 27 '08 #1
0 1359

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: cppaddict | last post by:
I thought that: char x; made x into a pointer-to-char. But how come the following code won't compile: int main() { char pbuf;
7
by: Ollej Reemt | last post by:
Hello, I would like to know if there is a difference in c++ between the following two method-declarations: void Method(); and void Method(void);
3
by: Dennis | last post by:
Excuse me!! I have a DLL file named "TESTDLL.DLL". In TESTDLL.DLL export function : void GetPChar(char** pstr); In .NET C# , How to call "GetPChar(char** pstr)" function ?
1
by: halise | last post by:
hello, i am trying to wrap an unmanaged C++ code to managed one so that i can use it within c#, and i am using IJW - "It Just Works" - method for that. In the code, there is a function which...
26
by: =?gb2312?B?wNbA1rTzzOzKpg==?= | last post by:
i wrote: ----------------------------------------------------------------------- ---------------------------------------- unsigned char * p = reinterpret_cast<unsigned char *>("abcdg");...
4
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, what is the use-case of parameter "start" in string's "endswith" method? Consider the following minimal example: a = "testing" suffix="ing" a.endswith(suffix, 2) Significance of...
4
by: Virtual_X | last post by:
some function make the data type of it's parameters as "const char*" why not use char or char* instead what would be different
14
by: Anna | last post by:
I try to put 8 int bit for example 10100010 into one character of type char(1 octet) with no hope . Could anyone propose a simple way to do it? Thank you very much.
13
by: xzzy | last post by:
None of the following properly do the VB.net double quote conversion because all of the following in csharp convert to \" instead of just a double quote: " I have tried: char...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.