Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

String Builder in C#

The String object is immutable.
A string requires a new allocation of space for every new object.
In situations where you need to perform repeated modifications to a string,a new String object can be costly.
The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object.

  1. using System;
  2. using System.Text;
  3.  
  4. namespace forgetCode
  5. {
  6. class program
  7. {
  8. public static void Main()
  9. {
  10. StringBuilder sb = new StringBuilder();
  11.  
  12. sb.AppendLine("Forget Code");
  13. sb.AppendLine("works");
  14. sb.AppendLine("nicely");
  15.  
  16. Console.Write(sb.ToString());
  17. }
  18. }
  19. }




Output:

Forget Code
works
nicely