PadLeft方法用于在字符串的左侧填充指定的字符,使字符串达到指定的长度。其语法如下:
public string PadLeft(int totalWidth, char paddingChar)参数说明:
totalWidth:指定填充后字符串的总长度。paddingChar:指定用于填充的字符。示例:
string str = "123";string paddedStr = str.PadLeft(5, '0');Console.WriteLine(paddedStr); // 输出:00123 

