TextBox换行
1public void fun()
2{
3textbox1.Multiline = true;
4textbox1.Text = "a" + "\r\n" + "b";
5}
1public void fun()
2{
3textbox1.Multiline = true;
4textbox1.Text = "a" + "\r\n" + "b";
5}
\r\n 缺一不可,顺序不可颠倒。
如果用Console.Write输出则情况如下
控制台输出
1public void consoleOutput()
2{
3 Console.Write("a" + "\r" + "b");
4 //result:
5 //a
6 //b
7
8 Console.Write("a" + "\n" + "b");
9 //result:
10 //a
11 //b
12
13 Console.Write("a" + "\r\n" + "b");
14 //result:
15 //a
16 //b
17
18 Console.Write("a" + "\n\r" + "b");
19 //result:
20 //a
21 //
22 //b
23
24 Console.Write("a" + "\r\n\r" + "b");
25 //result:
26 //a
27 //
28 //b
29
30 Console.Write("a" + "\r\n\n" + "b");
31 //result:
32 //a
33 //
34 //b
35}
1public void consoleOutput()
2{
3 Console.Write("a" + "\r" + "b");
4 //result:
5 //a
6 //b
7
8 Console.Write("a" + "\n" + "b");
9 //result:
10 //a
11 //b
12
13 Console.Write("a" + "\r\n" + "b");
14 //result:
15 //a
16 //b
17
18 Console.Write("a" + "\n\r" + "b");
19 //result:
20 //a
21 //
22 //b
23
24 Console.Write("a" + "\r\n\r" + "b");
25 //result:
26 //a
27 //
28 //b
29
30 Console.Write("a" + "\r\n\n" + "b");
31 //result:
32 //a
33 //
34 //b
35}