Click to See Complete Forum and Search --> : System::String::Format vs CString::Format


Laurent W
December 9th, 2003, 06:56 AM
How to use String::Format with multi parameters.

I want to convert
CString toto;
toto.Format("My String %s %s %s %02d %6.2lf", myStr1, myStr2, myStr3,myint,myDouble);

to

String *toto;
toto = String::Format ("My String {0} {1} {2} {3} {4}",myStr1, myStr2, myStr3,__box(myint), __box (myDouble) );

If i do that, firstly i have an compilation error saying there is too much parameters for String::Format. Secondely, I don't how to replace %02d or %6.2lf by the equivalent format parameters for String.
:confused:

Any help will be welcome

voidspace
December 9th, 2003, 01:31 PM
Originally posted by Laurent W
How to use String::Format with multi parameters.

I want to convert
CString toto;
toto.Format("My String %s %s %s %02d %6.2lf", myStr1, myStr2, myStr3,myint,myDouble);

to

String *toto;
toto = String::Format ("My String {0} {1} {2} {3} {4}",myStr1, myStr2, myStr3,__box(myint), __box (myDouble) );

If i do that, firstly i have an compilation error saying there is too much parameters for String::Format. Secondely, I don't how to replace %02d or %6.2lf by the equivalent format parameters for String.
:confused:

Any help will be welcome

String::Format is not a static function

use toto->Format
%02d %6.2lf is converted to string format when Format is used.