How to call MC++ code from a C# class

  • Thread starter Thread starter Henke
  • Start date Start date
H

Henke

Hi!

I have a managed C++ class that takes a char * as a parameter. How can I
call it from my C# class, that is how to convert from a System.String to a
char *?

Thanks!

/Henke
 
Henke,
I have a managed C++ class that takes a char * as a parameter. How can I
call it from my C# class, that is how to convert from a System.String to a
char *?

If it's MC++, why don't you make the parameter type a System::String
instead and then handle the conversion to char* internally in the C++
code? That would be a lot more friendly to other .NET languages.



Mattias
 
Doesn't I have to declare a System::String* as the parameter not
System::String?
If I have to declare a pointer then I get the same problem to convert from a
System.String to a System::String*?

/Henke
 
Doesn't I have to declare a System::String* as the parameter not
System::String?

Right, sorry, forgot the *.

If I have to declare a pointer then I get the same problem to convert from a
System.String to a System::String*?

No, System.String in C# == System::String* in MC++. The level of
indirection that a reference type reference has is hidden from you in
C#.



Mattias
 
Back
Top