C# 中的 Environment.NewLine
C# 中的 Enviornment.NewLine 用于添加换行符。
在单词中间设置新行 -
str = "This is demo text!" + Environment.NewLine + "This is demo text on next line!";
代码如下 -
示例
using System; using System.IO; namespace Demo { class Program { static void Main(string[] args) { string str = "This is demo text!" + Environment.NewLine + "This is demo text on next line!"; Console.Write(str); } } }
输出
This is demo text! This is demo text on next line!
广告