8 Replies
oh I forgot
BitConverter
was a thing, sorry
Both should be fine I think, although BinaryPrimitives.WriteInt32BigEndian
might be a bit more efficient, but that's not really something you should worry aboutHowever i must ask, the BinaryPrimitives class has both big endian and little endian methods
what would be the difference?
and compared to just GetBytes?
the latter doesnt make that distinction
(this is a bit low-level)
An int is 4 bytes. Say if we have the number
134480385
, we can write it in two ways:
Big endian puts the most significant byte first, little endian puts the least significant byte first, 00000001
being the least significant byte and 00001000
being the most significant.very well that makes sense, but GetBytes does that do big or little endian?
i would assume it depends on the endianness of the architecture
which is little endian for basically any modern system
bitconverter is an older API anyway, i'd prefer BinaryPrimitives
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Random.NextBytes Method (System)
Fills the elements of a specified span of bytes with random numbers.
yes i eventually settled on this thank you