Re: casting Object to byte array
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 27 Apr 2005 18:14:23 +0100
glenn <ghan***@xxxxxxxxxxxxxxxxxx> wrote:
> Nevermind, I think I figured it out, here is what I did so anyone can
> correct me if I am going to find a problem with this later on...
>
> Byte [] b = new byte[1023];
> b = (byte [])myobj;
>
> The problem was I was not adding the square brackets in my casting and was
> getting errors.
That's fine, except you're creating a new byte array for no reason -
just generating garbage.
Just use:
byte[] b = (byte[]) myobj;
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: casting Object to byte array
- From: glenn
- Re: casting Object to byte array
- References:
- casting Object to byte array
- From: glenn
- Re: casting Object to byte array
- From: glenn
- casting Object to byte array
- Prev by Date: Re: Double and Parse
- Next by Date: Re: Question from a transforming VB guy on Global Variable
- Previous by thread: Re: casting Object to byte array
- Next by thread: Re: casting Object to byte array
- Index(es):