C# 字符串多行显示、文本换行

以textbox为例

        ①:先设置textbox的属性Multiline为true

        ②:组织好显示字符串:FistLine(第一行要显示的字符)、SecondLine(第二行要显示的字符)、。。。。。。。、第n行字符

        ③:textbox.text="FistLine"+System.Environment.NewLine+"SecondLine"+System.Environment.NewLine+。。。。+"第N 行"+System.Environment.NewLine

   当你看到上面代码的时候可能会认为我们一般用的换行符不是"\r\n"吗

  你会想到这种方式:textbox.text="FistLine"+“\r\n”+"SecondLine"+"\r\n"+。。。。+"第N 行"+"\r\n"

 这种格式可能在运行时也不会出错,但在Linux操作系统或其他系统可能就会出错

posted @ 2018-03-30 10:58  易小川  阅读(4069)  评论(0编辑  收藏  举报