if i'm getting 8 bits from a source and i put those 8 bits into a byte, how can i then store away this byte? each byte is part of a message (which was once a string) I don't know how many bytes i'll end up with - hence using a byte array is not really an option. can i store it in a string? I want to be able to re-assemble the string after i get all the bytes, how would i do this?
using the method below to make 8 bits into a byte..
public byte GetByte(BitArray array){
Byte byt = 0;
for (int i = 7; i >= 0; i--){
byt = (byte)((byt << 1) | (array[i] ? 1 : 0));
}
return byt;
}
i can call it by doing this...
byte valueInByte = GetByte(bitsOfMessage);
i was thinking i could do this...
bytesOfTheMessage += (valueInByte.ToString() + "+"); //bytesOfTheMessage is a string
but then... i have a bunch of byte values in a string... i need to extract and convert, but what do i convert to. The very first value that i get back is "138" which is supposed to be the number 2 - when converted back to it's original form. i can tell that all the right values are there within the string as there is a pattern and it is consistent with the original string that i converted into bits.. any idea on what i should do?