string - C# : delete repetitive character -


this question has answer here:

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

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -