在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
隐式转换可能在多种情形下发生,包括调用方法时和在赋值语句中。 int 的大小(4 字节),即可显示变量的剩余字节。 class ClassConvert { static void Main() { int number = 1024; unsafe { // Convert to byte: byte* p = (byte*)&number; System.Console.Write("The 4 bytes of the integer:"); // Display the 4 bytes of the int variable: for (int i = 0 ; i < sizeof(int) ; ++i) { System.Console.Write(" {0:X2}", *p); // Increment the pointer: p++; } System.Console.WriteLine(); System.Console.WriteLine("The value of the integer: {0}", number); // Keep the console window open in debug mode. System.Console.WriteLine("Press any key to exit."); System.Console.ReadKey(); } } } /* Output: The 4 bytes of the integer: 00 04 00 00 The value of the integer: 1024 */
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论