Search code examples
c#bitconverter

BitConvert.IsLittleEndianon on different endian architectures


The documentation of BitConverter.IsLittleEndian says:

Indicates the byte order ("endianness") in which data is stored in this computer architecture.

"this" is confusing me. Say I have the following code:

Console.WriteLine(BitConverter.IsLittleEndian);

Now say I go to compile my program on my little endian machine. If I copy paste the executable onto a big endian machine, will it say false? or true? Basically I want to know if the field is a dynamic one, and if the JIT has anything to do with it.


Solution

  • BitConverter.IsLittleEndian indicates the architecture of the machine your binary is running on, not the one you're compiling on. It's checked entirely at runtime.