Arguments to String::Format

K

Kevin Burton

I have the following code:

Trace::WriteLine(String::Format(S"{0} {1} {2} {3}",
Marshal::ptrToStringAnsi(s->Line1),
Marshal::ptrToStringAnsi(s->Line2),
Marshal::ptrToStringAnsi(s->Line3),
Marshal::ptrToStringAnsi(s->Line4)));

But the compiler complains that there is no overload for
String::Format that takes 5 arguments. With C# this is
rather simple. I am not sure how to proceed with C++. Any
suggestions?

Thank you.

Kevin
 
J

Jochen Kalmbach

Kevin said:
I have the following code:

Trace::WriteLine(String::Format(S"{0} {1} {2} {3}",
Marshal::ptrToStringAnsi(s->Line1),
Marshal::ptrToStringAnsi(s->Line2),
Marshal::ptrToStringAnsi(s->Line3),
Marshal::ptrToStringAnsi(s->Line4)));

But the compiler complains that there is no overload for
String::Format that takes 5 arguments. With C# this is
rather simple. I am not sure how to proceed with C++. Any
suggestions?

The C# compiler knowns the ParamArrayAttribute and therefor can convert the
4 parameters to an array.
The managed C++ does not know (or cannot handle) this attribute, therefor
you have to do it by hand.
Maybe in a next version the managed C++ compiler is also a little bit more
intelligent...


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/useritems/leakfinder.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top