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!!
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.
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