10转16进制

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

  1. using System;
  2.  
  3. namespace MissTest {
  4. class Program {
  5. static void Main( string[] args ) {
  6.  
  7. long order = long.MaxValue;
  8. Console.WriteLine( "long.MaxValue={0}, Length={1}", order, order.ToString().Length );
  9.  
  10. //10转16
  11. string order16 = order.ToString( "X16" );//补满16 byte
  12. Console.WriteLine("16进制表示: {0}, Length={1}", order16, order16.Length);
  13.  
  14. //16转10
  15. long order10 = long.Parse( order16, System.Globalization.NumberStyles.AllowHexSpecifier );
  16. Console.WriteLine( "还原为10进制: {0}, Length={1}", order10, order10.ToString().Length );
  17.  
  18. Console.ReadKey();
  19. }
  20. }
  21. }

运行效果

long转16进制.png

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号