private void mtlBtnLogin_Click(object sender, EventArgs e) {
public static byte[] GetBitsArray(byte value) { if (value == 0) return new byte[0]; byte[] bArray = { value }; BitArray objBitArray = new BitArray(bArray); byte[] bResult = new byte[objBitArray.Count]; for (int iCount = 0; iCount < objBitArray.Count; iCount++) { bResult[iCount] = Convert.ToByte(objBitArray[iCount]); } return bResult; } public static byte GetBitsToByteValue(bool bit0, bool bit1, bool bit2, bool bit3, bool bit4, bool bit5, bool bit6, bool bit7) { bool[] blArray = { bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7 }; byte value = 0x00; for (byte x = 0; x < 8; x++) { value |= (byte)((blArray[x]) ? (0x01 << x) : 0x00); } return value; } public static byte GetBitsToByteValue(params bool[] blArray) { byte value = 0x00; for (byte x = 0; x < blArray.Length; x++) { value |= (byte)((blArray[x]) ? (0x01 << x) : 0x00); } return value; } public static byte ConvertToByte(BitArray bits) { if (bits.Count != 8) { return 1; } byte[] bytes = new byte[1]; bits.CopyTo(bytes, 0); return bytes[0]; }
private void mtlBtnLogin_Click(object sender, EventArgs e) { byte x = GetBitsToByteValue(true, false, false, false, true, true, true,false); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)