简体   繁体   中英

How to display integers in messagebox in Visual C#?

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

System.Windows.Forms.MessageBox.Show(myGame.P2.Money);

However the variable Money is an integer, and so I get this error:

Argument '1': cannot convert from 'int' to 'string'

How do I get this to work?

你试过了吗:

System.Windows.Forms.MessageBox.Show(myGame.P2.Money.ToString());

Have you tried

System.Windows.Forms.MessageBox.Show(myGame.P2.Money.ToString());

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM