Well, simple options are:
string.Format
:
string x = string.Format("first line{0}second line", Environment.NewLine);
String concatenation:
string x = "first line" + Environment.NewLine + "second line";
String interpolation (in C#6 and above):
string x = $"first line{Environment.NewLine}second line";
You could also use
everywhere, and replace:
string x = "first line
second line
third line".Replace("
",
Environment.NewLine);
Note that you can't make this a string constant, because the value of Environment.NewLine
will only be available at execution time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…