I would like to know if using a BinaryReader in a MemoryStream created from an array of bytes ( byte[] ) can significantly reduce performance.
There is binary data that I want to read, and I get this data as an array of bytes. I am currently deciding between two approaches to reading data and should accordingly implement a variety of reading methods. After each reading action, I need a position immediately after the data being read, and therefore I am considering using BinaryReader . The first, non-BinaryReader approach:
object Read(byte[] data, ref int offset);
Second approach:
object Read(BinaryReader reader);
Such Read() methods will be called very often, sequentially from the same data, until all the data has been read.
So, using BinaryReader seems more natural, but does it have a big impact on performance?
source share