How To Use \n In a TextBox

后端 未结 4 995
再見小時候
再見小時候 2021-01-01 11:34

I\'m developing a program that I\'m using a string(generatedCode) that contains some \\n to enter a new-line at the textBox that I\'m using it(

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-01 12:08

    since using \n is easier on the eyes (especailly when formatting), and also sometimes you don't control how the source string is constructed - I find best practice is to use:
    TextBox1.Text = str.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);

提交回复
热议问题