I’m currently having a problem with some Socket stuff.
The output that I want is 0x5801, which reversed is 0x0158which is actually 344 as ushort.
ushort t = 344;
p.WriteString("\x58\x01", false);
I now want to have the variable instead of the hardcoded hex. I already tried with some ReverseBit classes and so on, but nothing really worked.
Thanks for your help!
Start off by not using
WriteString. You want to write binary data, right? So either useWriteShortor write the bytes directly.You haven’t given much information to work with (like the type of
p, or what this data is meant to represent) but if this is a problem of endianness, you could consider using my MiscUtil which hasEndianBinaryWriterandEndianBinaryReaderwhich are like the frameworkBinaryWriterandBinaryReaderclasses, but with the ability to specify endianness.