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; } 

reference


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -