c# windows10大小端试

测试代码:

cs 复制代码
unsafe public void ceshi()
{
    byte[] by = BitConverter.GetBytes(0x12345678);
    Debug.WriteLine(" byte[0] = 0x" + by[0].ToString("x2"));
    Debug.WriteLine(" byte[1] = 0x" + by[1].ToString("x2"));
    Debug.WriteLine(" byte[2] = 0x" + by[2].ToString("x2"));
    Debug.WriteLine(" byte[3] = 0x" + by[3].ToString("x2"));

    for( int i = 0; i < 4;i ++)
    {
        fixed (byte* pB = &by[i])
        {
            ulong addr = (ulong)pB; // 得到内存的地址
            Debug.WriteLine($" byte[{i}]地址 = 0x" + addr.ToString("x2"));
        }
    }
}

输出结果

byte0 = 0x78

byte1 = 0x56

byte2 = 0x34

byte3 = 0x12

byte0地址 = 0x29a7af0

byte1地址 = 0x29a7af1

byte2地址 = 0x29a7af2

byte3地址 = 0x29a7af3

结论:

0 = 低字节

3 = 高字节

参考链接

单片机大小端模式-CSDN博客https://blog.csdn.net/anlog/article/details/135338624

特此记录

anlog

2024年1月5日

相关推荐
yue0084 小时前
winform控件篇-按钮
c#
DevOpenClub8 小时前
Markdown、HTML 和 PPT 如何稳定交付:文档转换任务的幂等发布流程
开发语言·前端·c#·html·powerpoint
软件黑马王子9 小时前
3.单例模式问题1:构造函数
开发语言·单例模式·c#
软件黑马王子10 小时前
4.单例模式问题2:重复挂载
开发语言·单例模式·c#
夏霞11 小时前
c# 不支持的目标框架 解决方案
开发语言·c#
软件黑马王子11 小时前
5.单例模式问题3:多线程问题
单例模式·前端框架·c#
geovindu11 小时前
CSharp: Template Method Pattern
开发语言·后端·c#·.net·模板方法模式·行为模式
CSDN_RTKLIB12 小时前
SetImpliedSelection
c#
软件黑马王子12 小时前
1.non-MonoBehaviour 单例模式泛型基类
unity·前端框架·c#
高彬13 小时前
SAP ECC6.0 对接 C# web Services服务
开发语言·前端·c#·sap