Replace whole characters in a string with one character
1 answer
As we all know, a string is a set of characters, so the constructor of the String class will help you create a string by repeating a character N
once. Here we can use this constructor to create. You can try like this:
string oldString = "Hello, world!";
string outStr = new String('-', oldString.Length);
Console.WriteLine(outStr);
Take a look at this working example
+6
source to share