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…
Excellent tutorial. Keep it up. I want to learn C#
Yup. Let’s learn C# together.