Rolls, Robert [mailto:[EMAIL PROTECTED]] wrote:

> How do I limit the amount of bytes copied on the assignment?
> or what can I
> do to achieve the following -
>
> byte[] data = new byte[4096];
> int bytesread=0;
> while((bytesread = streamthing.read( data, 0, data.Length )) > 0 ) {
>
>  //** The line below makes the oData have a length of 4096
> when all I need
> is the bytesread?
>  object oData = data;
>
>  DoSomething( ref oData );
> }

I think you'll find that oData will always have a Length of 4096 because
that's what you allocated data as. If you want to something with only a
portion of the array, (i.e. 0 to bytesread - 1) then you'll need to pass
bytesread as additional information to whomever is using the array.

HTH,
Drew
.NET MVP

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to