Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly read 16 byte unsigned integer with BinaryReader

I need to parse a binary stream in .NET to convert a 16 byte unsigned integer. I would like to use the BinaryReader.ReadUIntXX() functions but there isn't a BinaryReader.ReadUInt128() function available. I assume I will have to roll my own function using the ReadByte function and build an array but I don't know if this is the most efficient method? Thanks!

like image 574
Brent Avatar asked Nov 30 '25 04:11

Brent


1 Answers

I think the comments from 0xA3, SLaks, and Darin Dimitrov answered the question but to put it all together. BinaryReader.ReadUInt128() is not supported in the binary reader class in .NET and the only solution I could find was to create my own function. As 0xA3 mentioned, there is a BigInt data type in .NET 4.0. I am in the process of creating my own function based upon everyone's comments. Thanks!

like image 82
Brent Avatar answered Dec 02 '25 18:12

Brent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!