Arguments to String::Format

  • Thread starter Thread starter Kevin Burton
  • Start date Start date
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
 
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
 
Back
Top