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 请按任意键继续. . . */
时间: 2024-10-26 04:02:03