简单的 Select 是:
string.Format
:
字符串连接:
string x = "first line" + Environment.NewLine + "second line";
字符串插值(C#6及以上版本):
string x = $"first line{Environment.NewLine}second line";
您还可以在所有位置使用\n,并替换:
string x = "first line\nsecond line\nthird line".Replace("\n",
Environment.NewLine);
请注意,您不能将其设置为字符串constant,因为值Environment.NewLine
仅在执行时可用.