Replacing a char at a given index in string? [duplicate]

Use a StringBuilder:

StringBuilder sb = new StringBuilder(theString);
sb[index] = newChar;
theString = sb.ToString();

Leave a Comment