C# string replace x number of characters in string code example
Example 1: c sharp string replace
// You can use the function 'Replace()' to replace all instances
// of a string or character with a given string or character.
str = "Hello World!"
str.Replace('o', 'e');
// Output: "Helle Werld!"
Example 2: replace index in string c#
using System.Text;
var theString = "ABCDEF";
var sb = new StringBuilder(theString);
sb[2] = "r" //replace letter at index 2 with "r"
theString = sb.ToString(); //theString: "ABrDEF"