开发者

MessageBox.Show("First Name,{0}", textBox1.Text);

I would like for the input from textbox1.text to be displayed in the place holder {0} so that if textbox1.text = "Randy" I would like a messagebox to popup and say Firstname,Randy

MessageBox.Show("First Name,{0}", textBox1.Text);

Wh开发者_运维百科at happens currently is a messagebox pops up and says First Name,{0}


There's no overload that does formatted output for the MessageBox class. Use String.Format() to get your formatted string.

MessageBox.Show(String.Format("First Name,{0}", textBox1.Text));

To show a message box with a caption, use the MessageBox.Show(string, string) overload. First argument is the message while the second is the caption.

MessageBox.Show(String.Format("First Name,{0}", textBox1.Text), // message
                textBox1.Text); // caption (title)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜