'String.Replace() is not working as expected to replace weird chars in strings in C# [duplicate]
I have a string DisplayName which has value as "Vinny' Direct Reports". I am trying to replace "'"with "-"in string as it failing to get ingested into my Data Source.
Below is the code where I am trying to replace.
if (DisplayName.Contains("'", StringComparison.OrdinalIgnoreCase) == true)
{
DisplayName.Replace("'", "-").Replace("\"", "-");
Console.WriteLine(DisplayName);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
