鸟语天空
10转16进制
post by:追风剑情 2014-12-22 17:43

using System;

namespace MissTest {
    class Program {
        static void Main( string[] args ) {

            long order = long.MaxValue;
            Console.WriteLine( "long.MaxValue={0}, Length={1}", order, order.ToString().Length );

            //10转16
            string order16 = order.ToString( "X16" );//补满16 byte
            Console.WriteLine("16进制表示: {0}, Length={1}", order16, order16.Length);

            //16转10
            long order10 = long.Parse( order16, System.Globalization.NumberStyles.AllowHexSpecifier );
            Console.WriteLine( "还原为10进制: {0}, Length={1}", order10, order10.ToString().Length );

            Console.ReadKey();
        }
    }
}

运行效果

long转16进制.png

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容