private Replace ( [ s, [ oldValue, [ newValue, System.StringComparison comparison ) : string | ||
s | [ | |
oldValue | [ | |
newValue | [ | |
comparison | System.StringComparison | |
return | string |
public static string Replace([NotNull] this string s, [NotNull] string oldValue, [NotNull] string newValue, StringComparison comparison) {
var index = s.IndexOf(oldValue, comparison);
return index != -1 ? s.Substring(0, index) + newValue + s.Substring(index + oldValue.Length) : s;
}