Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0251 Append a line to StringBuilder

To add a whole new line to a StringBuilder we can use the AppendLine method: using System; using System.Text; class Sample { public static void Main() { StringBuilder sb = new StringBuilder(); string[] strs = new string[] { "a", "v", "c" }; foreach (string s in strs) { sb.AppendLine(s); } Console.WriteLine(sb); } } The output: a v c