William Sullivan <Wi*************@discussions.microsoft.com> wrote:
string foo = "v:\\bar.txt";
is equivalent to:
string foo = @"v:\bar.txt";
foo.Replace(@"\\",@"\");
has no effect on 'foo', due to String being immutable.
if(foo == "v:\\bar.txt")
is equivalent to:
if(foo == @"v:\bar.txt")
[...]
This should do what you're after:
const string StringWithCuriousDoubleSlash = @"v:\\bar.txt";
string foo = StringWithCuriousDoubleSlash;
foo = foo.Replace(@"\\",@"\");
if (foo != StringWithCuriousDoubleSlash
MessageBox.Show("Success.");