10转16进制

作者:追风剑情 发布于:2014-12-22 17:43 分类:C#

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

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号