String.Replace not working

When I run this and after this line, I check the Comment by mousing over it in VS, but the strings are not replaced.  The strings in the params are definitely different so it should have replaced the strings and the Comment definitely has the string it's looking for.

newOrder.Comment.Replace(oldFileName.Substring(0, oldFileName.IndexOf("-")), newFileName.Substring(0, newFileName.IndexOf("-")));

CoffeeAddictAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jjardineCommented:
newOrder.Comment = newOrder.Comment.Replace(oldFileName.Substring(0,oldFileName.IndoexOf("-")),newFileName.Substring(0,newFileName.IndexOf("-")));
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that's normal, because the replace function returns the string with the replaces characters, it does not replace direclty in the variable
newOrder.Comment = newOrder.Comment.Replace(oldFileName.Substring(0, oldFileName.IndexOf("-")), newFileName.Substring(0, newFileName.IndexOf("-")));

Open in new window

0
p_davisCommented:
that method returns a string -- it doesn't directly modify the string itself
newOrder.Comment = newOrder.Comment.Replace...
0
CoffeeAddictAuthor Commented:
Thank you for explaining.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.