A List<byte> would provide this exact behavior for you. Internally it deals with a buffer but encapsulates a seperate length than the length on the buffer.
Cheers, Greg On 7/6/06, Chris Anderson <[EMAIL PROTECTED]> wrote:
How about reading the data into a small intermediate buffer array first. Then when that's full, or you've finished reading, copy the appropriate number of bytes from that buffer into your large array. Also, out of interest, how are you dynamically expanding your array? -----Original Message----- From: "dave wanta"<[EMAIL PROTECTED]> Sent: 06/07/06 19:01:06 To: "ADVANCED-DOTNET@DISCUSS.DEVELOP.COM"< ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Subject: [ADVANCED-DOTNET] trim byte array hi all, does anyone know of an efficient way to trim a byte array? Here is what is happening. I'm reading in some binary data into a dynamically expanding byte array, until all of the data has been read into memory. I need to trim the byte array to remove the trailing nulls. Because the amount of data is large (100megs+), I don't want to simply create a 2nd 100meg+ byte array in memory, and then copy it. So, is there anyway to trim the existing byte array, and then return it? Thanks, Dave =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com -----Unmodified Original Message----- hi all, does anyone know of an efficient way to trim a byte array? Here is what is happening. I'm reading in some binary data into a dynamically expanding byte array, until all of the data has been read into memory. I need to trim the byte array to remove the trailing nulls. Because the amount of data is large (100megs+), I don't want to simply create a 2nd 100meg+ byte array in memory, and then copy it. So, is there anyway to trim the existing byte array, and then return it? Thanks, Dave =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor� http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
-- If knowledge can create problems, it is not through ignorance that we can solve them. Isaac Asimov