Confuser.Core/Utils.cs
/// <summary>
///     Returns a new string in which all occurrences of a specified string in
///     <paramref name="str" /><paramref name="str" /> are replaced with another specified string.
/// </summary>
/// <returns>
///     A <see cref="string" /> equivalent to <paramref name="str" /> but with all instances of
///     <paramref name="oldValue" />
///     replaced with <paramref name="newValue" />.
/// </returns>
/// <param name="str">A string to do the replace in. </param>
/// <param name="oldValue">A string to be replaced. </param>
/// <param name="newValue">A string to replace all occurrences of <paramref name="oldValue" />. </param>
/// <param name="comparison">One of the <see cref="StringComparison" /> values. </param>
/// <remarks>Adopted from http://stackoverflow.com/a/244933 </remarks>
Returns a new string in which all occurrences of a specified string in
are replaced with another specified string.
Returns a new string in which all occurrences of a specified string in are replaced with another specified string .
public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison)
        {
            StringBuilder sb = new StringBuilder();
            int previousIndex = 0;
            int index = str.IndexOf(oldValue, comparison);
            while (index != -1)
            {
                sb.Append(str.Substring(previousIndex, index - previousIndex));
                sb.Append(newValue);
                index += oldValue.Length;
                previousIndex = index;
                index = str.IndexOf(oldValue, index, comparison);
            }
            sb.Append(str.Substring(previousIndex));
            return sb.ToString();
        }
public static string Replace ( this string str , string oldValue , string newValue , StringComparison comparison ) { StringBuilder sb = new StringBuilder ( ) ; int previousIndex = 0 ; int index = str . IndexOf ( oldValue , comparison ) ; while ( index != - 1 ) { sb . Append ( str . Substring ( previousIndex , index - previousIndex ) ) ; sb . Append ( newValue ) ; index += oldValue . Length ; previousIndex = index ; index = str . IndexOf ( oldValue , index , comparison ) ; } sb . Append ( str . Substring ( previousIndex ) ) ; return sb . ToString ( ) ; }
Returns a new string in which all occurrences of a specified string in
are replaced with another specified string.
Returns a new string in which all occurrences of a specified string in are replaced with another specified string .
A  equivalent to  but with all instances of

replaced with .
A equivalent to but with all instances of replaced with .
string
this
oldValue
string
A string to be replaced.
A string to be replaced .
newValue
string
A string to replace all occurrences of .
A string to replace all occurrences of .
comparison
StringComparison
One of the  values.
One of the values .
str
A string to do the replace in.
A string to do the replace in .
remarks
None