string - C# : delete repetitive character -
this question has answer here:
- replace “\\” “\” in string in c# 7 answers
in c# application, desktop folder doing :
string path = environment.getfolderpath(environment.specialfolder.desktopdirectory);
which gives string : "c:\\users\\username\\desktop".
see there 2 slashes, problematic. there easy way delete slash each time meet them ?
thank in advance.
just know, "\\" 1 character - backslash escape character (it used in things \r or \n). since escape character, string representation of actual backslash, have escape it, leading double backslash, "\\".
tldr: "\\" in string represents single backslash.
if want verify this, try printing out string "\\".
in general, remove duplicate character, can use .replace function:
mystring.replace("xx", "x");
Comments
Post a Comment