By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,024 Members | 924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,024 IT Pros & Developers. It's quick & easy.

Corrected: string.Replace acts unexpectedly in this case

P: n/a
Grrrr... I couldn't edit my previous post. Lemme short circuit the obvious
reply by fixing my code.

string foo = @"v:\\bar.txt";
if(foo == @"v:\\bar.txt)
MessageBox.Show("Why didn't Replace replace?");
Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

Replace doesn't modify the existing string (because strings are
immutable), it returns a new string. Change that line to

foo = foo.Replace(@"\\",@"\");


Mattias Sjögren [MVP] mattias @ |
Please reply only to the newsgroup.
Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.