I want to store Guids in a database which does not support Guid/uniqueidentifier data type, therefore I convert Guid to byte array using .ToByteArray() method. However, this method converts value in a strage way:
11223344-5566-7788-9900-AABBCCDDEEFF
will become
44, 33, 22, 11, 66, 55, 88, 77, 99, 00, AA, BB, CC, DD, EE, FF
As I understand, this is because of endian ordering.
I would like to know if this method will return the same result on every platform (86x hardware, 64x hardware, Linux, Windows etc) and there will be no changes in byte order no matter on which platform I run my software.
For your question:
I would like to know if this method will return the same result on every platform (86x hardware, 64x hardware, Linux, Windows etc)
Yes it will be same for all the platforms.
However, this method converts value in a strage way:
The order returned from ToByteArray
would be different from string representation.
See: Guid.ToByteArray Method
Note that the order of bytes in the returned byte array is different from the string representation of a Guid value. The order of the beginning four-byte group and the next two two-byte groups is reversed, whereas the order of the last two-byte group and the closing six-byte group is the same.
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