String::Format() doesn't take integer as param object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is the code snippet:
....
int nTest = 10;
String * pMsg = String::Format( "Display an integer here: {0}", nTest);
....

I got the following error message when tried to compile the program:
error C2665: 'System::String::Format' : none of the 5 overloads can convert
parameter 2 from type 'int'

Am I missing anything here?
 
Dilbert said:
This is the code snippet:
...
int nTest = 10;
String * pMsg = String::Format( "Display an integer here: {0}", nTest);
...

I got the following error message when tried to compile the program:
error C2665: 'System::String::Format' : none of the 5 overloads can
convert
parameter 2 from type 'int'

Am I missing anything here?

Please consult the docs before posting, in this case the 2nd argument must
be an object, so you have to box the int.

...., __box(nTest));

Willy.
 
Back
Top