473,386 Members | 1,715 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,386 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 1365

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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.