### Byte to Binary String

Example Sub to convert a Byte in its Hex representation.
'Convert a Byte to its Binary string
`Sub ByteToBinaryString(b As Byte) As String
Dim bc As ByteConverter
Dim hex As String = bc.HexFromBytes(Array As Byte(TestByte))
Dim binarystring As String = Bit.ToBinaryString(Bit.ParseInt(hex, 16))
Dim sb As StringBuilder
sb.Initialize
For i = binarystring.Length - 8 To binarystring.Length - 1
If i < 0 Then
sb.Append("0")
Else
sb.Append(binarystring.CharAt(i))
End If
Next
Return sb.ToString
End Sub`
Output Example for a Byte with Value 15
Binary String from Byte: 00001111

Changed: , Category: Bit and Bytes, File: T6C166M1219.htm, ID: 1219