There is no built-in method for this, but you can write an extension method:
static class StringExtensions { public static string Splice(this string str, int start, int length, string replacement) { return str.Substring(0, start) + replacement + str.Substring(start + length); } }
Usage is as follows:
string sad = "sad"; string bad = sad.Splice(0, 1, "b");
Note that the first character in a string in C # is number 0, not 1, as in your SQL example.
If you want, you can call the Stuff method, of course, but perhaps the name Splice little clearer (although it is not used very often).
Thorarin
source share