Passing a "str.basic_string" from C#

  • Thread starter Thread starter ScottyO
  • Start date Start date
S

ScottyO

Hello,

I have some legacy C++ code that was re-written as a managed class. I made
a C++ class library with it and I want to use it in my C# program.

I created a reference to it and it instantiates the object ok, but when I go
to use one of it's methods I have a problem.

The method requires a "basic_string" from the std library. I do not know
what to do to get a basic_string from C# into this method. Here's the code
fragment:

Ini ini = new Ini(); // the C++ class library object
ini.Read(basic_string needed as argument); // Here's where I need the
basic_string.

I tried using string from C# to no avail, the compiler just wants a
basic_string. When I try to instantiate a basic_string such as;
std.basic_string<char> str (cstr1, 5);
the compiler barks at me on <char>
"Invalid expression term "char" "

Any one out there know how to do this??

Scott
 
ScottyO said:
I have some legacy C++ code that was re-written as a managed class. I
made
a C++ class library with it and I want to use it in my C# program.

I assume you converted your C++ classes to __gc classes and build a managed
library, please correct me if I'm wrong.
Anyway, you can't use the stl lib in C# this is ONLY possible in C++ and
MC++.
So you need to rewrite your Read method, so it takes a System::String as
argument, the Read method can convert this String to a std string when
needed.


Willy.
 
Back
Top