
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to replace a character with asterisks in a sentence
Use the Replace() method to replace a character with asterisks.
Let’s say our string is −
string str = "dem* text";
To replace it, use the Replace() method −
str.Replace('*', 'o');
Here is the complete code −
Example
using System; public class Program { public static void Main() { string str = "dem* text"; Console.WriteLine("Initial string = " + str); string res = str.Replace('*', 'o'); // after replacing Console.WriteLine("After replacing asterisk = " + res.ToString()); } }
Output
Initial string = dem* text After replacing asterisk = demo text
- Related Questions & Answers
- Python Program to replace a word with asterisks in a sentence
- Java Program to replace a word with asterisks in a sentence
- PHP program to replace a word with a different symbol in a sentence
- C# Program to convert first character uppercase in a sentence
- C Program to convert first character uppercase in a sentence
- C# Program to replace a special character from a String
- Java Program to replace all occurrences of a given character with new character
- Program to reverse a sentence words stored as character array in C++
- C program to replace all occurrence of a character in a string
- Java Program to convert first character uppercase in a sentence
- Java Program to Replace the Spaces of a String with a Specific Character
- Java Program to Replace a Character at a Specific Index
- C++ Program to find matrix with marked asterisks region
- C# program to replace n-th character from a given index in a string
- C Program to read and write character string and sentence
Advertisements