I need to replace some of the words in the sentence. But how am I going to do so? Let’s say, I have this sentence as example.

I love to eat durian very much.

I want to replace the word “durian” with “apple”. Just follow below C# source code to replace it.

String sentence = “I love to eat durian very much.”;
sentence = sentence.Replace(”durian”, “apple”);

You will get the output like this…

I love to eat apple very much.

Based on the example above, just key in 2 parameters in String.Replace(”old value“, “new value“). The “new value” will replace “old value”.
Enjoy coding…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Google
  • Live
  • YahooMyWeb
  • Furl
  • Slashdot
  • Spurl
  • Mixx
  • BlinkList
  • Bumpzee

Tags: ,