using System; public class OctetString { private byte[] m_bDataArray = null; public OctetString(byte[] data_i) { //copy input data m_bDataArray = new byte[data_i.Length]; data_i.CopyTo(m_bDataArray, 0); } //... //checks if a bit on a specfied position is set public bool CheckIfBitOnPositionIsSet(int iPosition) { if (m_bDataArray.Length * 8 < iPosition) { return false; } int iByte = iPosition / 8; int iBit = iPosition % 8; byte bData = m_bDataArray[iByte]; if((bData & (0x1 << iBit)) != 0) { return true; } else { return false; } } } public class Test { public static void Main() { byte[] data = { 0xFF, 0x3F, 0x00 }; OctetString octetString = new OctetString(data); bool isSet = octetString.CheckIfBitOnPositionIsSet(15); System.Console.Out.WriteLine("{0:d}", isSet); } }