c# - how to convert bool array to char variable? -
i have boolean array holds values represent ascii value:
bool[] myboolreceived = new bool[8];
i try convert char can add list holds chars.
myreceivedmessage = new list<char>();
i tried use convert.tochar
method not seems work.
char contains 2 bytes. can convert bool array byte , convert character using convert
class.
public byte converttobyte(bool[] arr) { byte val = 0; foreach (bool b in arr) { val <<= 1; if (b) val |= 1; } return val; }
Comments
Post a Comment