鸟语天空
补位PadLeft()与PadRight()
post by:追风剑情 2018-11-27 21:22

示例

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

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容