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日

相关推荐
z落落3 小时前
C#ToolStrip+StatusStrip 状态栏实时显示系统时间+NotifyIcon系统托盘
开发语言·c#
ctrl_v助手4 小时前
VisionPro (R) QuickBuild相机的连接
服务器·笔记·数码相机·c#
北域码匠5 小时前
奇偶归并排序:并行计算的排序利器
数据结构·算法·c#·排序算法
zhangfeng11335 小时前
国家超算中心 昆山站 异构加速卡1 显存16GB详细配置, 海光 Z100SM HCU
linux·网络·深度学习·c#
z落落5 小时前
C# WinForm TreeView 树形控件+ListView控件+菜单栏
开发语言·c#
ABprogramming6 小时前
Aspire入门指南
c#·.net
加号36 小时前
【C#】VS2022 传统 ASP.NET Web 服务(.asmx)接口实现指南
前端·c#·asp.net
加号318 小时前
【C#】 文件与目录管理:创建、删除操作的技术解析
开发语言·c#
用户395240998801 天前
SqlSugar 连接 PostgreSQL 报错 42P01: relation does not exist 的排查与修复
c#
2601_961875241 天前
法考考试时间安排及科目|时间表|资料已整理
开发语言·c#·inverted-index·suffix-tree·sstable·r-tree·lsm-tree