Meta.StringExtensions.Replace C# (CSharp) Method

Replace() public static method

public static Replace ( this originalString, string oldValue, string newValue, System.StringComparison comparisonType ) : string
originalString this
oldValue string
newValue string
comparisonType System.StringComparison
return string
        public static string Replace(this string originalString, string oldValue, string newValue, StringComparison comparisonType)
        {
            int startIndex = 0;
            while (true)
            {
                startIndex = originalString.IndexOf(oldValue, startIndex, comparisonType);
                if (startIndex == -1)
                    break;

                originalString = originalString.Substring(0, startIndex) + newValue + originalString.Substring(startIndex + oldValue.Length);

                startIndex += newValue.Length;
            }

            return originalString;
        }