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日

相关推荐
aini_lovee3 小时前
C# 快递单打印系统(万能套打系统)
开发语言·c#
白菜上路3 小时前
C# Serilog.AspNetCore基本使用
c#·serilog
小白不白1114 小时前
C# WinForm 与 VP 二次开发
开发语言·c#
SunnyDays10115 小时前
如何使用 C# 自动调整 Excel 行高和列宽
开发语言·c#·excel
itgather5 小时前
OfficeExcel — Word / Excel DLL 验证台功能介绍
c#·word·excel
云中小生6 小时前
Scrutor:.NET 依赖注入自动化的优雅实现
c#·.net
郝亚军6 小时前
Visual Studio 2022项目中的.sln是什么?
c++·c#·visual studio
jghhh016 小时前
C# 图片水印工具(支持9个位置)
数据库·microsoft·c#
咸鱼翻身小阿橙6 小时前
C# WinForms 控件学习项目
开发语言·学习·c#
JaydenAI7 小时前
[MAF预定义Agent中间件-03]FunctionInvocationDelegatingAgent:将AOP引入函数调用
ai·c#·agent·aop·maf