如果 BitConverter.IsLittleEndian
被硬编码为 真
最佳答案
没有。 C#可以编译运行在dotnetcore下。在这里,您将 IsLittleEndian
硬编码为 true
的假设是不正确的。它在编译时被硬编码为一个值,但这可能是true
或false
,具体取决于编译目标。
参见 https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/BitConverter.cs#L21
#if BIGENDIAN
[Intrinsic]
public static readonly bool IsLittleEndian /* = false */;
#else
[Intrinsic]
public static readonly bool IsLittleEndian = true;
#endif
显然,虽然 .NET/dotnet core 不支持,但 Mono 可以针对一些大端架构。
关于c# - 在 C# 中序列化在 C# 中反序列化 BitConverter 和 Endianness 保证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56789938/