首页 > 代码库 > Convert PadLeft Bit Operate
Convert PadLeft Bit Operate
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。