使用填充下面给出的代码似乎没有按照原样播放,理论上文本“ADD this text”应该从第21列开始在两个字符串中,但在str2中它有一个几个额外的空间。在检查两个琴弦的长度时,结果与预期的相同。
字符串填充问题
string str1 = "Test".PadRight(20);
string str2 = "Test123".PadRight(20);
string common = "Add this text";
MessageBox.Show(str1.Length.ToString());
MessageBox.Show(str2.Length.ToString());
MessageBox.Show(str1 + common + "\n" + str2 + common);
任何人都遇到过这个问题吗?有什么明显的我缺少。
很多谢谢。
同样的事情发生在TextBox,TextBlock等。 – 2009-04-18 10:37:21