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);
What 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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With