Converting byte array to short array?

O

Ole

Hi,

Is there a better / faster way to convert a byte array to a short array than
to use Convert.toInt16(bytearray, i) in a loop?

Thanks
Ole
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Yes. Don't call the Convert.ToInt16 method, it's not needed when you
convert a byte to a short. All it does is:

public static short ToInt16(byte value)
{
return value;
}

As to the loop, it can't be avoided. As a byte and short are of
different size, you can't copy the data using any block copy method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top