How to Replace a Character with the String in C#? Last Updated : 03 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Syntax: string.Replace(character, new_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. Examples: 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 Approach: To replace a character with the specified string follow the following step: Declare a stringUse 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 Example: C# // C# program to replace a character // with a specified string using System; class GFG{ public static void Main() { // Define string String input_string = "A portal in India"; Console.WriteLine("Actual String : " + input_string); // Replace the string 'A' with 'Geeks For Geeks' Console.WriteLine("Replaced String: " + input_string.Replace("A", "Geeks For Geeks")); } } Output: Actual String : A portal in India Replaced String: Geeks For Geeks portal in India Comment More infoAdvertise with us Next Article How to Remove Special Characters from a String in Ruby? G gottumukkala_sivanagulu Follow Improve Article Tags : C# CSharp-programs CSharp-Strings-Programs Similar Reads Convert a Character to the String in C# Given a character, the task is to character to the string in C#. Examples: Input : X = 'a' Output : string S = "a" Input : X = 'A' Output : string S = "A" Approach: The idea is to use ToString() method, the argument is the character and it returns string converting Unicode character to the string. / 1 min read How to replace a text in a string with another text using PHP ? A string is a sequence of one or more characters. A string is composed of characters, each of which can be replaced easily in the script. A large number of in-built PHP methods can be used to perform string replacements. Table of ContentUsing str_replace() method - The str_replace() Using str_irepla 4 min read How to remove all characters from StringBuilder in C# StringBuilder.Clear Method is used to remove all the characters from the current StringBuilder instance. Syntax: public System.Text.StringBuilder Clear (); It returns an StringBuilder object whose length will be zero. Note: Clear is a convenience method that is equivalent to setting the Length prope 1 min read How to Remove Special Characters from a String in Ruby? In this article, we will discuss how to remove special characters from a string in Ruby. In Ruby, special characters can be removed from a string using various methods. Special characters typically include punctuation marks, symbols, and non-alphanumeric characters. Let us explore different methods 2 min read How to replace a portion of strings with another value in JavaScript ? In JavaScript, replacing a portion of strings with another value involves using the `replace()` method or regular expressions. This process is essential for text manipulation tasks like formatting, sanitization, or dynamic content generation in web development and data processing applications. We ca 3 min read How to replace all dots in a string using JavaScript ? We will replace all dots in a string using JavaScript. There are multiple approaches to manipulating a string in JavaScript. Table of Content Using JavaScript replace() MethodUsing JavaScript Split() and Join() Method Using JavaSccript reduce() Method and spread operatorUsing JavaScript replaceAll() 4 min read Like