MessageBox::Show 中需要 C++/CLI 帮助
我正在使用 C++/CLI 构建一个项目,其中我必须在其中一个表单中显示一个消息框。
内容必须是 std::string 和 int 的组合。
但我无法获得正确的语法。
我尝试了以下操作:
std::string stringPart = "ABC";
int intPart = 10;
MessageBox::Show("Message" + stringPart + intPart);
我也尝试过:
String^ msg = String::Concat("Message", stringPart);
msg = String::Concat(msg, intPart);
MessageBox::Show(msg);
有人可以帮我解决语法问题吗?
谢谢。
I am building a project in C++/CLI where in I have to show a message box in one of my forms.
The content has to be a combination of std::string and int.
But I am not able to get the right syntax.
I tried the following:
std::string stringPart = "ABC";
int intPart = 10;
MessageBox::Show("Message" + stringPart + intPart);
I also tried:
String^ msg = String::Concat("Message", stringPart);
msg = String::Concat(msg, intPart);
MessageBox::Show(msg);
Can someone please help me with the syntax.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是
std::string
是非托管的,无法分配给托管System::String
。解决方案是编组。请参阅此 MSDN 页面:http://msdn.microsoft.com/en-us/ library/bb384865.aspx所以这里是解决方案(对于 Visual Studio):
Your problem is thar
std::string
is unmanaged and cannot be assigned to managedSystem::String
. Solution is marshalling. See this MSDN page: http://msdn.microsoft.com/en-us/library/bb384865.aspxSo here is the solution (for Visual Studio):