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

I would like the input from textbox1.text to be displayed in the place holder {0} so if textbox1.text = "Randy", I would like the message popup to say the name First, Randy

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

A popup is currently occurring with the message "Name", {0}

+3
source share
1 answer

There is no overload that outputs formatted output for a class MessageBox. Use String.Format()to get a formatted string.

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

To display a message box with a header, use overload MessageBox.Show(string, string). The first argument is the message, and the second is the signature.

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

Source: https://habr.com/ru/post/1774009/


All Articles