/// <summary>
/// 做一个string类的静态扩展类,添加一个静态方法,给长度不够的字符串加一个空格
/// </summary>
public static class getnewString
{
public static string newString(this String str, int setLength)
{
int preLength = str.Length;
if (str.Length < setLength)
{
for (int i = 0; i < setLength - preLength; i++)
{
str += " ";
}
}
return str;
}
}
做一个string类的扩展方法
最新推荐文章于 2020-04-19 12:44:06 发布