如何在 Visual C# 的消息框中显示整数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1806265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display integers in messagebox in Visual C#?
提问by neuromancer
I am trying to use a messagebox to debug a Visual C# program. When I click a button I want a simple messagebox to popup and display the values of several integer variables. This is what I have
我正在尝试使用消息框来调试 Visual C# 程序。当我单击一个按钮时,我想要一个简单的消息框弹出并显示几个整数变量的值。这就是我所拥有的
System.Windows.Forms.MessageBox.Show(myGame.P2.Money);
However the variable Money is an integer, and so I get this error:
但是变量 Money 是一个整数,所以我得到这个错误:
Argument '1': cannot convert from 'int' to 'string'
参数“1”:无法从“int”转换为“string”
How do I get this to work?
我如何让这个工作?
采纳答案by Donald Byrd
Did you try:
你试过了吗:
System.Windows.Forms.MessageBox.Show(myGame.P2.Money.ToString());
回答by Bruno Reis
Have you tried
你有没有尝试过
System.Windows.Forms.MessageBox.Show(myGame.P2.Money.ToString());
?
?