String.Replace to replace \ (slash)

D

David C

I have tried

newstring = oldstring.Replace(Convert.ToChar(92), ' ');

newstring = oldstring.Replace("\\", " ");

Neither of which works. I am tring to take out all \ (slashes). Please help.
 
J

Jon Skeet [C# MVP]

David C said:
I have tried

newstring = oldstring.Replace(Convert.ToChar(92), ' ');

newstring = oldstring.Replace("\\", " ");

Neither of which works. I am tring to take out all \ (slashes). Please help.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

As Anders said, both of the above will work.
 

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

Top