How to format a string displayed in a MessageBox in C#?

.net, c#, string, wpf

Solution

Try something like this:

string strMsg = String.Format("Machine\t: {0}\nUser\t: {1}", "TestMachine", "UserName");

Edited: Gotta have that String.Format there or that lone bracket at the end is sad.

Problem

I want to display a string in a message box with a following format: Machine : TestMachine User : UserName I am doing this: ``` string strMsg = "Machine :" + "TestMahine" + "\r\n" + "User :" + "UserName"; ``` MessageBox.Show(strMsg); When I do this the message box do not display a string as formated above. Colon(") dosen't keep alligned. The above format is also do not work in WPF TextBlock control. Please help!!

Original source