[Solved] Show String Data in Message Box C#


Try this:

MessageBox.Show(String.Format("{0}, {1}, {2}:", city, zip, state));

This go replace {0} with the variable city, {1}with the variable zip and {3} with state.

String.Format converts the value of objects to strings based on the formats specified and inserts them into another string.

If you are new, read getting started with the String.Format method

New in C# 6 is this:

MessageBox.Show($"{city}, {zip}, {state}");

Commented by @Lucas Trzesniewski


Another opinion is use this:

MessageBox.Show(city + ", " + zip  + ", " + state);

Just past it all together.

5

solved Show String Data in Message Box C#