Method Replace
Replace(string, string, string, StringComparison, bool)
Returns a new string in which all occurrences of a specified string in the source string are replaced with another specified string.
public static string Replace(this string source, string oldString, string newString, StringComparison comparison, bool firstOccurrenceOnly = false)
Parameters
source
stringSource string to process.
oldString
stringThe string to be replaced.
newString
stringThe string to replace all occurrences of oldString.
comparison
StringComparisonOne of the enumeration values that specifies the rules for the replacement.
firstOccurrenceOnly
boolReplace only first occurrence.
Returns
- string
A string that is equivalent to the source string except that all instances of oldString are replaced with newString.