replace

  • Thread starter Thread starter Eugene Anthony
  • Start date Start date
E

Eugene Anthony

For the code bellow I am receiving a new line error.

String s = "C:\My document\Mama";
s = s.Replace("\","/");

How do I solve the problem?


Eugene Anthony
 
Keep in mind, a \ is an escape character. When you put \", you're telling
the compiler that you want to put a " in the string. To ensure that \ is
seen as a \, you have to escape it by putting two of them together like so:
\\.

In the replace try the following: s = s.Replace("\\","/");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Invoking an exe file 3
code execution sequence 2
file upload 2
validating date of birth 1
file size 1
Store Carriage Returns as <br /><br /> or <p></p> 2
insert code - security 2
How do I use a class? 3

Back
Top