How to append line to existing string using StringBuilder in C#

1 Answer

0 votes
using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder("line 1");

            sb.AppendLine();
            sb.Append("line 2");

            Console.WriteLine(sb);
        }
    }
}

/*
run:
  
line 1
line 2

*/


answered Feb 24, 2015 by avibootz

Related questions

2 answers 215 views
1 answer 131 views
1 answer 206 views
1 answer 100 views
1 answer 139 views
1 answer 130 views
...