Try:
byte[] b1 = new byte[] { 1, 2, 3, 4 };
sbyte[] b2 = new sbyte[4];
for (int i = 0; i < 4; i++)
b2
= (sbyte)b1;
Using explicit casting of the individual elements, this can do it without an
intermediate cast. I tested it on both 1.1 and 2.0 platforms.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
David Thielen said:
Tried:
byte[] data = new byte[4];
data[1] = 3;
short[] d2 = (short[])data;
Got the error:
error VJS1333: Cannot cast from 'byte[]' to 'short[]'
--
thanks - dave
Kevin Spencer said:
You could implicitly convert it to short[] and then implicitly convert
short[] to sbyte[], and vice versa.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
Hi;
Is there a way to cast a byte[] to a sbyte[]? I know I can copy it but
if
I
have a 32K array, that copy takes time & memory and yet the actual
values
are
identical in both arrays.
So is there some way to cast a variable in this case?