I want to replace ","
with a ;
in my string.
For example:
Change
"Text","Text","Text",
to this:
"Text;Text;Text",
I've been trying the line.replace( ... , ... )
, but can't get anything working properly.
Try this:
line.Replace("\",\"", ";")
The simplest way is to do
line.Replace(@",", @";");
Output is shown as below:
You need to escape the double-quotes inside the search string, like this:
string orig = "\"Text\",\"Text\",\"Text\"";
string res = orig.Replace("\",\"", ";");
Note that the replacement does not occur "in place", because .NET strings are immutable. The original string will remain the same after the call; only the returned string res
will have the replacements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With