January 28, 2016
How to Replace a String in C#/CSharp
To replace a string in C#/CSharp, we make use Replace method. Example is given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
using System; using System.IO; namespace Hello_World { class Program { static void Main(string[] args) { string hello = "Hello World"; string myString = hello.Replace("World", "FWait"); Console.WriteLine(myString); } } } |