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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.