Xiao Peng

My personal blog moves to xiaopeng.me , blogs about design patterns will be synced to here.
肖鹏,ThoughtWorks资深咨询师,目前关注于架构模式、敏捷软件开发等领域,并致力于软件开发最佳实践的推广和应用。
多次为国内大型企业敏捷组织转型提供咨询和培训服务,在大型团队持续集成方面具有丰富的经验。
  博客园  :: 首页  :: 联系 :: 订阅 订阅  :: 管理

“会者不难”的数字进制转换

Posted on 2007-06-06 10:00  勇敢的鸵鸟  阅读(260)  评论(0编辑  收藏  举报

QQ群游僧提供!

十进制转二进制、八进制、十六进制,及其翻转。

            //Decimal to bin

            Console.WriteLine(Convert.ToString(100, 2));

            //Decimal to octal

            Console.WriteLine(Convert.ToString(100, 8));

            //Decimal to hexa

            Console.WriteLine(Convert.ToString(100, 16));

 

            //Bin to Dec

            Console.WriteLine(Convert.ToInt32("1100100", 2));

            //Oct to Dec

            Console.WriteLine(Convert.ToInt32("144", 8));

            //Hexa to Dec

            Console.WriteLine(Convert.ToInt32("64", 16));

 

输出结果如下:

1100100
144
64
100
100
100