Case-Insensitive String Replacement in C#

added by DotNetKicks
1/20/2020 4:37:17 PM

440 Views

The C# string class provides a convenient method for replacing one string with another. The syntax is string.Replace ( , ); So the following code: var oldName = "David"; var newName = "Mr. Giard"; var oldSentence = "My name is David"; var newSentence = oldSentence.Replace(oldName, newName); stores the value "My name is Mr. Giard" in the variable newSentence.


0 comments