I was hoping you didn't say that! looks as though I need copy to another
array as then assign to the object - the object is sent via com interop to a
third party library.

-----Original Message-----
From: Marsh, Drew [mailto:[EMAIL PROTECTED]]
Sent: Friday, 24 May 2002 9:57
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Byte[] to object


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.


**********************************************************************"
This correspondence is for the named person's use only. It may
contain confidential or legally privileged information or both. "
No confidentiality or privilege is waived or lost by any "
mistransmission.  If you receive this correspondence in error, please
immediately delete it from your system and notify the sender.  You
must not disclose, copy or rely on any part of this correspondence
if you are not the intended recipient.

Any views expressed in this message are those of the individual sender,
except where the sender expressly, and with authority, states them to
be the views of Vodafone.

This email has been checked for viruses.
**********************************************************************************************

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