473,399 Members | 3,832 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,399 software developers and data experts.

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


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?
Nov 17 '05 #1
2 1238

"Dilbert" <Di*****@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...

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.
Nov 17 '05 #2

"Dilbert" <Di*****@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...

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.
Nov 17 '05 #3

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

Similar topics

2
by: san | last post by:
Hello, all! I have question about String.Format method. There are two variants: public static string Format(string, params object); and public static string Format(IFormatProvider, string, params...
2
by: Bob | last post by:
I'm having trouble the string.Format() throwing exceptions and I can't figure out what I am doing wrong. Given the following setup code: string str = { "one", "two", "three", "four" }; double...
2
by: Akeel | last post by:
Hi I have the following code char splitter={','}; string fields=row.ToString().Split(splitter) string serviceDefintion="" // row.ToString().Split(splitter // conatins the followin...
0
by: Dilbert | last post by:
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:...
1
by: Chris Morse | last post by:
Hi, I've been trying to figure out where in the documentation it describes all the String.Format() formatting specifiers. So far, I've been guessing and picking up specifiers in sample code.....
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
1
by: Remi THOMAS | last post by:
Hi, When you execute this line of code string script = string.Format("foreach (GroupDoc gdoc in {0}.SetGroup(\"{1}\") {\r\n", "p1", "p2"); You get System.FormatException was unhandled...
10
by: John Vottero | last post by:
Why does String.Format have overrides of: Format(string, object) Format(string, object, object) Format(string, object, object, object) Format(string, params object) doesn't the last one...
7
by: Rick | last post by:
With String.Format, if I have an incorrect number of args specified for a format string, compile fails. How can I implement similar design-time functionality for my own string functions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.