How to Replace a Character with the String in C#?
Given a string, now our task is to replace a specified character with the string. This task is performed with the help of Replace() method. This method is used to replace all the Unicode characters with the specified string and return a modified string.
Here, string is the input string, a character is present in the string that is going to replace, and new_string is the string that replaces the character.
Input: A portal in India Replace A with Hello Output: Hello portal in India Input: Python is not equal to java Replace is with was Output: Python was not equal to java
To replace a character with the specified string follow the following step:
- Declare a string
- Use Replace() function to replace the character(i.e., “A”) with string(i.e., “Geeks For Geeks”))
input_string.Replace("A", "Geeks For Geeks")
- Display the modified string
Actual String : A portal in India Replaced String: Geeks For Geeks portal in India