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(); } } }
运行效果