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…
2 Responses
Dumb Web Programmer
July 29th, 2008 at 4:48 pm
1Excellent tutorial. Keep it up. I want to learn C#
Jayce
July 29th, 2008 at 4:54 pm
2Yup. Let’s learn C# together.
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Chat Chat Chat...
SP Blogger
Isabell Online Penang Florist