convert int[] to byte[]



Is there a way to convert int[] to byte[] easily?

I want to write my int[] indexTbl to a MemoryStream but the MemoryStream
class only accepts byte[] buffer. I have more than one int[] indexTbl to
write to the stream so it would be nice if I could just write the whole int[]
as a block and then read it back later when needed.

I thought the Buffer class might be handy here but it seems to be best for
converting byte[] to int[] with Block Copy.

Any suggestions here. I am new to C# and wanted to avoid a for-loop and
convert each int to a byte and then write to the stream one by one.
.



Relevant Pages

  • Re: pipedstreams
    ... time readInt returns values that has never been written to the stream ... to put the wrapped streams into your Comm object. ... catch (IOException e){System.err.println("An error occured ... public synchronized void send(int dest, ...
    (comp.lang.java.programmer)
  • Re: Sending XML data via socket
    ... I looked int a link you have provided. ... // Get a stream object for reading and writing ... Resize the buffer, put in the byte we've just ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: adapting getline
    ... int getline; ... The function reads characters from the input stream stream and stores them ...
    (comp.lang.c)
  • Re: how to remove code duplication
    ... the log directory should containing the same files as the out ... exit(EXIT_FAILURE); ... int main ... void process_log_data(FILE *stream) ...
    (comp.lang.c)
  • Re: Why doesnt std::cin choke on this?
    ... when I was writing a user-driven test program for a data structure I ... You read an int. ... it simpler then checking the stream for it's ... read in a string, this becomes trivial. ...
    (comp.lang.cpp)