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
sourcestringSource string to process.
oldStringstringThe string to be replaced.
newStringstringThe string to replace all occurrences of oldString.
comparisonStringComparisonOne of the enumeration values that specifies the rules for the replacement.
firstOccurrenceOnlyboolReplace only first occurrence.
Returns
- string
A string that is equivalent to the source string except that all instances of oldString are replaced with newString.