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

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -