I like to build a function that takes params....
private void ShowMsg(string fmt, params object[] prms)
{
MessageBox.Show(string.Format(fmt, prms));
}
ShowMsg("Answer: {0}", answer);
-mdb
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
generallee5686 <u18038@uwe> wrote: Just a quick question, im just taking a C# class.
Is there a way to have a variable inside a text string like:
Console.Write("Answer: {0}",answer);
But instead do it inside of a MessageBox.Show(
Use string.Format:
MessageBox.Show (string.Format ("Answer: {0}", answer),
...);