码迷,mamicode.com
首页 > 其他好文 > 详细

Convert PadLeft Bit Operate

时间:2017-05-04 12:04:43      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:span   eric   ogr   using   collect   main   bit   pad   opera   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleAppConvert
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10;i++ )
            {
                String str = Convert.ToString(i).PadLeft(8, 0);
                Console.WriteLine(str);
            }
            Console.WriteLine("=================================");
            byte b = 0xC1;
            if ((b>>7)!=0)
            {
                Console.WriteLine("{0} ‘s bit 8 is 1", Convert.ToString(b, 2).PadLeft(8, 0));
            } 
            else
            {
                Console.WriteLine("{0} ‘s bit 8 is 0", Convert.ToString(b, 2).PadLeft(8, 0));
            }

            b = 0x41;
            if ((b >> 7) != 0)
            {
                Console.WriteLine("{0} ‘s bit 8 is 1", Convert.ToString(b, 2).PadLeft(8, 0));
            }
            else
            {
                Console.WriteLine("{0} ‘s bit 8 is 0", Convert.ToString(b, 2).PadLeft(8, 0));
            }
/*
11000001 ‘s bit 8 is 1
01000001 ‘s bit 8 is 0           
*/
            ///////////////////////////////////////
        }
    }
}
/*
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
请按任意键继续. . . 
 */

 

Convert PadLeft Bit Operate

标签:span   eric   ogr   using   collect   main   bit   pad   opera   

原文地址:http://www.cnblogs.com/sky20080101/p/6806142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!