我需要获取带有 8 个“*”符号的字符串。我如何在 .NET 3.5 中做到这一点? .NET 4.0?
谢谢。
尝试:
string str = new string('*', 8);
我自己的快速解决方法:
"".PadLeft(Password.Length,'*')
:)
但我想这应该是更好的解决方案。
谢谢。
这对我有用
private static string WelcomeString = "wordsandstuff";
private static Int32 padInt = WelcomeString.Length;
public static void Main(string[] args)
{
Console.WriteLine(WelcomeString);
Console.WriteLine("".PadLeft(padInt, '='));
Console.ReadKey();
}