二进制读取四个字节 怎么换位呢? 本帖最后由 priceyao 于 2009-08-01 15:28:03 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 UInt32 lengthOfApp1 = binReader.ReadUInt32(); lengthOfApp1 = (ushort)(lengthOfApp1 < <16 | lengthOfApp1 >>16); 不行?Uint32就是4个字节的。4个字节的一半就是2个字节,16位啊 用Uint32读 并按你说的(lengthOfApp1 < <16 | lengthOfApp1 >>16 改成16变量只得到了第3和第4个字节,我想读的是全部四个字节 的确是读了四个字节 但只付给变量两个字节 UInt32 temp = binReader.ReadUInt32(); temp = (ushort)(mthd << 16 | mthd >> 16); MessageBox.Show(Convert.ToString(temp,16));前四个字节是4d 54 68 64 现在megbox只显示 64 68 (ushort)是这个的问题。。去掉 static void Main(string[] args) { UInt32 temp = Convert.ToUInt32( Console.ReadLine()); Console.WriteLine(Convert.ToString(temp, 16)); temp = (temp << 16 | temp >> 16); Console.WriteLine( Convert.ToString(temp, 16)); }222222221e88ee88e0021请按任意键继续. . . static void Main(string[] args) { UInt32 temp = Convert.ToUInt32(Console.ReadLine()); Console.WriteLine(Convert.ToString(temp, 16)); UInt16 U16d = (ushort)temp, U16g = (ushort)(temp >> 16); Console.WriteLine("{0} {1}", Convert.ToString(U16g, 16), Convert.ToString(U16d, 16)); U16g = (ushort)(U16g << 8 | U16g >> 8); U16d = (ushort)(U16d << 8 | U16d >> 8); temp = (UInt32)(U16g << 16 | U16d); Console.WriteLine(Convert.ToString(temp, 16)); }一次读32位 C#怎么将CSV内容导入到SQL数据库中 背景色改变不了 给点意见 各位高人,xml里我想他做数据源绑定,并且有条件地,比如“id=1”怎么写?高手帮忙! C#数据连接的问题?? 水晶报表数据分组跳页控制问题!顶者有分,快来抢分! 关于WinForm控件重绘速度慢的问题 C#读取文本内容问题 关于 c# 的 winForm中用到msflexgrid com组件问题,没人遇到过吗??? C# 如何捕获串口断开和tcp/udp被动断开 谁能帮我注解一下DBHelper每一句是什么意思?急!!! C#windows窗体button设置打印预览
lengthOfApp1 = (ushort)(lengthOfApp1 < <16 | lengthOfApp1 >>16); 不行?
Uint32就是4个字节的。
4个字节的一半就是2个字节,16位啊
变量只得到了第3和第4个字节,我想读的是全部四个字节
的确是读了四个字节 但只付给变量两个字节
UInt32 temp = binReader.ReadUInt32();
temp = (ushort)(mthd << 16 | mthd >> 16);
MessageBox.Show(Convert.ToString(temp,16));前四个字节是4d 54 68 64 现在megbox只显示 64 68
去掉
{
UInt32 temp = Convert.ToUInt32( Console.ReadLine());
Console.WriteLine(Convert.ToString(temp, 16));
temp = (temp << 16 | temp >> 16);
Console.WriteLine( Convert.ToString(temp, 16));
}
2222222
21e88e
e88e0021
请按任意键继续. . .
{
UInt32 temp = Convert.ToUInt32(Console.ReadLine());
Console.WriteLine(Convert.ToString(temp, 16));
UInt16 U16d = (ushort)temp, U16g = (ushort)(temp >> 16);
Console.WriteLine("{0} {1}", Convert.ToString(U16g, 16), Convert.ToString(U16d, 16));
U16g = (ushort)(U16g << 8 | U16g >> 8);
U16d = (ushort)(U16d << 8 | U16d >> 8);
temp = (UInt32)(U16g << 16 | U16d);
Console.WriteLine(Convert.ToString(temp, 16));
}一次读32位