Redian新闻
>
String::Format doesn't take integer type params
avatar
String::Format doesn't take integer type params# DotNet - 窗口里的风景
P*s
1
Here is the code snippet ( managed C++)
...
Int32 nTemp = 10;
String * pMsg = String::Format("Display an integer here: {0}", nTemp);
...
I got an error message when tried to compile the program:
error C2665: 'System::String::Format' : none of the 5 overloads can convert pa
rameter 2 from type 'int'
Am I missing anything here? Thanx in advance.
avatar
r*y
2

nTemp.ToString()
then ok

【在 P********s 的大作中提到】
: Here is the code snippet ( managed C++)
: ...
: Int32 nTemp = 10;
: String * pMsg = String::Format("Display an integer here: {0}", nTemp);
: ...
: I got an error message when tried to compile the program:
: error C2665: 'System::String::Format' : none of the 5 overloads can convert pa
: rameter 2 from type 'int'
: Am I missing anything here? Thanx in advance.

avatar
P*s
3
Thanks for the reply. I also found another solution:
String::Format("....", __box(nTemp));
The __box() keyword wraps the integer as an object.

nTemp.ToString
()
then ok

【在 r****y 的大作中提到】
:
: nTemp.ToString()
: then ok

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。