I have this string: "123-456-7"
I need to get this string: "1234567"
How I can replace occurrences of "-" with an empty string?
Replace(';',string. Empty. ToCharArray()[0]) or Replace(";", "") also works.
Using 'str.replace() , we can replace a specific character. If we want to remove that specific character, replace that character with an empty string. The str. replace() method will replace all occurrences of the specific character mentioned.
replace() method to replace all spaces in a string, e.g. str. replace(/ /g, '+'); . The replace() method will return a new string with all spaces replaced by the provided replacement.
string r = "123-456-7"; r = r.Replace("-", "");
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