473,385 Members | 1,326 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,385 software developers and data experts.

Passing a "str.basic_string" from C#

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

Nov 16 '05 #1
1 2033

"ScottyO" <of*****@nswccd.navy.mil> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
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.
Nov 16 '05 #2

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

Similar topics

7
by: ma740988 | last post by:
The string object value_f doesn't produce the right output. At issue, - I suspect - is the conversion from string to int with istringstream. An alternate approach? Thanks in advance #include...
2
by: Gianni Mariani | last post by:
I'm getting "multiply defined" errors on STL symbols. Isn't this a linker error ? By definition, doesn't the compiler/linker need to guarentee the "one definition rule". Linking... ...
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
2
by: john | last post by:
In a query I have this expression: Expr1: "ZH"+Str() It should give me ZH1234 but it adds a space between the 2 parts so I get ZH 1234. What can I do to prevent this? Thanks, john
10
by: lovecreatesbea... | last post by:
Is it correct and safe to compare a string object with "", a pair of quotation marks quoted empty string?If the string object: s = ""; does s contain a single '\'? Is it better to use...
8
by: John Nagle | last post by:
The Python documentation for "str" says "str() : Return a string containing a nicely printable representation of an object." However, there's no mention of the fact that "str" of a Unicode...
1
by: bcwhite | last post by:
I'm writing a program and want to create a class that is derived from the "str" base type. When I do so, however, I have problems with the __init__ method. When I run the code below, it will call...
13
by: arnuld | last post by:
/* C++ Primer 4/e * section 3.2 - String Standard Library * exercise 3.10 * STATEMENT * write a programme to strip the punctation from the string. */ #include <iostream> #include...
3
by: Ge Chunyuan | last post by:
hi Group: Once use ActivePython latest version for Python 2.5.1. I happened to find function "str" is not callable, but it is available for Python 2.5. Can anybody give some comments about it?...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.