String.Replace to replace \ (slash)

  • Thread starter Thread starter David C
  • Start date Start date
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.
 
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.
 
Back
Top