补位PadLeft()与PadRight()

作者:追风剑情 发布于:2018-11-27 21:22 分类:C#

示例

using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace Test2
{
    class Program
    {
        static void Main(string[] args)
        {
            int code = 31;
            string padleft = Convert.ToString(code, 16).PadLeft(6, '0');
            string padright = Convert.ToString(code, 16).PadRight(6, '0');
            Console.WriteLine("左补位: " + padleft);
            Console.WriteLine("右补位: " + padright);
            Console.Read();
        }
    }
}

运行测试

1111.png

标签: C#

Powered by emlog  蜀ICP备18021003号   sitemap

川公网安备 51019002001593号