Excuse the poor wording, but I couldn't find a better way to explain it.
From my understanding, C# is a WORA language- you can write it on one machine and deploy it on another, because the MSIL isn't compiled until the application is actually run.
So then why is it that BitConverter.IsLittleEndian
is defined like so:
#if BIGENDIAN
public static readonly bool IsLittleEndian /* = false*/;
#else
public static readonly bool IsLittleEndian = true;
#endif
BIGENDIAN
here is a preprocessor directive, which means that it's resolved at compile-time. So if the developer's machine is little endian, and the target uses big endian, will IsLittleEndian
still report true
on the target machine?
No, it will work as expected. The reason it'll work is because the .NET runtime installed on the target system was built/compiled for that target system, so it's BitConverter.IsLittleEndian
property will return false
. Your code is simply referencing that property, so it isn't determined until runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With