I have two strings
string str1 = "Hello World !"; // the position of W character is 6
string str2 = "peace";
//...
string result = "Hello peace !"; // str2 is written to str1 from position 6
Is there a function like this:
string result = str1.Rewrite(str2, 6); // (string, position)
EDITED
This “Hello World !” is just an example, I don’t know whether there is “W” character in this string, what I only know are: str1, str2, position (int)
@danludwigs answer is better from a code understandability perspective, however this version is a tad faster. Your explanation that you are dealing with binary data in string format (wtf bbq btw 🙂 ) does mean that speed might be of the essence. Although using a byte array or something might be better than using a string 🙂