C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String Replace()The C# Replace() method is used to get a new string in which all occurrences of a specified Unicode character in this string are replaced with another specified Unicode character. There are two methods of Replace() method. You can replace string also. Signaturepublic string Replace(Char first, Char second) public string Replace(String firstString, String secondString) Parameterfirst: it is a first parameter of char type. second: it is a second parameter of char type. ReturnIt returns a string. C# String Replace() Method Exampleusing System; public class StringExample { public static void Main(string[] args) { string s1 = "Hello F#"; string s2 = s1.Replace('F','C'); Console.WriteLine(s2); } } Output: Hello C# C# String Replace() Method Example 2using System; public class StringExample { public static void Main(string[] args) { string s1 = "Hello C#, Hello .Net, Hello TheDeveloperBlog"; string s2 = s1.Replace("Hello","Cheers"); Console.WriteLine(s2); } } Output: Cheers C#, Cheers .Net, Cheers TheDeveloperBlog
Next TopicC# String Split()
|