How to fill a string with a required character

I need to get a string with 8 '*' characters. How can I do this in .NET 3.5? .NET 4.0?

Thank.

+3
source share
2 answers

Try:

string str = new string('*', 8);
+10
source

My own quick workaround:

"".PadLeft(Password.Length,'*')

:)

But I think this should be the best solution.

Thank.

+1
source

Source: https://habr.com/ru/post/1782453/


All Articles