Complete the code to append a string to the StringBuilder.
var sb = new StringBuilder(); sb.[1]("Hello"); Console.WriteLine(sb.ToString());
The Append method adds the specified string to the end of the StringBuilder.
Complete the code to insert a string at the beginning of the StringBuilder.
var sb = new StringBuilder("World"); sb.[1](0, "Hello "); Console.WriteLine(sb.ToString());
The Insert method inserts a string at the specified index, here at position 0 (the start).
Fix the error in the code to remove 5 characters starting at index 6.
var sb = new StringBuilder("Hello, World!"); sb.[1](6, 5); Console.WriteLine(sb.ToString());
The Remove method deletes a specified number of characters starting at a given index.
Fill both blanks to replace 'World' with 'C#' in the StringBuilder.
var sb = new StringBuilder("Hello, World!"); sb.[1]("World", [2]); Console.WriteLine(sb.ToString());
The Replace method replaces all occurrences of a string with another string. Here, 'World' is replaced with 'C#'.
Fill all three blanks to create a StringBuilder, append 'Hello', insert 'C# ', and remove 1 character at index 5.
var sb = new [1](); sb.[2]("Hello"); sb.[3](0, "C# "); sb.Remove(5, 1); Console.WriteLine(sb.ToString());
First, create a StringBuilder object. Then Append adds 'Hello' at the end. Next, Insert adds 'C# ' at the start. Finally, Remove deletes one character at index 5.