mh_frame_sps/APT.Infrastructure.Core/Extensions/Int32Extensions.cs

35 lines
1.3 KiB
C#
Raw Permalink Normal View History

2026-04-07 13:47:52 +08:00
using System;
namespace APT.Infrastructure.Core
{
/// <summary>
/// 类型<see cref="System.Int32"/>扩展方法类
/// </summary>
public static class Int32Extensions
{
/// <summary>
/// 返回一个新字符串,该字符串通过在此实例中的字符左侧填充指定的 Unicode 字符来达到指定的总长度,从而使这些字符右对齐。
/// </summary>
/// <param name="source"></param>
/// <param name="totalWidth"></param>
/// <param name="paddingChar"></param>
/// <returns></returns>
public static String PadLeft(this Int32 source, int totalWidth, char paddingChar)
{
return source.ToString().PadLeft(totalWidth, paddingChar);
}
/// <summary>
/// 返回一个新字符串,该字符串通过在此字符串中的字符右侧填充指定的 Unicode 字符来达到指定的总长度,从而使这些字符左对齐。
/// </summary>
/// <param name="source"></param>
/// <param name="totalWidth"></param>
/// <param name="paddingChar"></param>
/// <returns></returns>
public static String PadRight(this Int32 source, int totalWidth, char paddingChar)
{
return source.ToString().PadRight(totalWidth, paddingChar);
}
}
}