replace index in string csharp

Code Example - replace index in string csharp

                
                        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"