如何:生成多行字符串 (Visual C#)

更新:2007 年 11 月

本示例说明两种构造多行字符串的方法。

示例

string myString1 = "This is the first line of my string.\n" +
                   "This is the second line of my string.\n" +
                   "This is the third line of the string.\n";
string myString2 = @"This is the first line of my string.
This is the second line of my string.
This is the third line of the string.";

编译代码

复制该代码,并将其粘贴到控制台应用程序的 Main 方法中。

请参见

概念

C# 语言入门

其他资源

Visual C# 速成版