📅  最后修改于: 2020-10-31 03:47:15             🧑  作者: Mango
C#PadRight()方法用于获取一个新字符串,该字符串将指定的总长度用右边的空格填充,从而使该字符串的字符左对齐。
public string PadRight(Int32 length)
public string PadRight(Int32, Char)
length:它是整数类型的参数。
它返回一个字符串。
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C#";// 8 length of characters
string s2 = s1.PadRight(15);
Console.Write(s2);//padding at right side (15-8=7)
Console.Write("JavaTpoint");//will be written after 7 white spaces
}
}
输出:
Hello C# JavaTpoint