How to insert a string before or every occurence of a string?

I've managed to code how to replace a word with a string, but I can't figure out how to add in front of or behind (2 different methods I need to create for the assignment) it. Can anyone please give my any points? This is my code for replacing if it helps giving you an idea of what I'm trying to do:

while ((i = sourceWord.IndexOf(searchWord, i)) != -1) 

 { i =i+ searchWord.Length;  count++; sourceString = sourceWord.Replace(searchWord, >replaceOrd);  

sourceString is a ref string I need to change. Count is the int the method is going to return.

by RamsayDidNothinWrong via /r/csharp

Leave a Reply