Need help with BynaryReader and SBytes

G

[Gauthier]

Hi,

I'm trying to populate a structure that contain sbyte[] (signed byte array)
with an instance of BinaryReader class, my problem is that I don't see
ReadSbytes(int count) method however there is a similar method for byte[]
(unsigned byte array).

So my question are:
-Is there any valid reason for the absence of the ReadSBytes method?
-What way shoud I use to populate my signed byte array easily?

Much thanks for your support

Gauthier
 
G

[Gauthier]

Anyway, I've just added theses members to a custom binaryreader class:

public sbyte[] ReadSBytes(int count)
{
return GetSBytesFromBytes(base.ReadBytes(count));
}
static sbyte[] GetSBytesFromBytes(byte[] bytes)
{
sbyte[] sbytes = new sbyte[bytes.Length];
for(int i = 0; i < sbytes.Length; i++)
{
sbytes = (sbyte) bytes;
}
return sbytes;
}

is there a better way to achieve this?

Thanks

Gauthier


| Hi,
|
| I'm trying to populate a structure that contain sbyte[] (signed byte
array)
| with an instance of BinaryReader class, my problem is that I don't see
| ReadSbytes(int count) method however there is a similar method for byte[]
| (unsigned byte array).
|
| So my question are:
| -Is there any valid reason for the absence of the ReadSBytes method?
| -What way shoud I use to populate my signed byte array easily?
|
| Much thanks for your support
|
| Gauthier
|
|
 

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

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top