Hi,
what's the best way to write the binary representation of an int array (Int32[]
) to a Stream
?
Stream.Write
only accepts byte[]
as source and I would like to avoid converting/copying the array to an byte[]
(array but instead streaming directly from the 'original location').
In a more system-oriented language (a.k.a. C++) I would simply cast the int array to a byte*
but as far as I understood this isn't possible with C# (and moreover, casting byte*
to byte[]
wouldn't work out either way)
Thanks
Martin
PS: Actually, I would also like to stream single int
values. Does using BinaryConverter.GetBytes()
create a new byte array? In this case I extend my question to how to efficiently stream single int
values ...