Class DataBlock.Base16Encoding
- Namespace
- TechnologySolutions.Rfid.AsciiProtocol
- Assembly
- TechnologySolutions.Rfid.AsciiProtocol.Core.dll
Provides methods to convert to and from Base16 encoding
public static class DataBlock.Base16Encoding
- Inheritance
-
DataBlock.Base16Encoding
- Inherited Members
Methods
Parse(string)
Parses a Base16 (hex) string and returns the byte array
public static byte[] Parse(string hex)
Parameters
hex
stringThe value to convert
Returns
- byte[]
The value as a byte array
Exceptions
- FormatException
If a character that is encountered that is not a hex digit or white-space or if the number of hex characters is odd (i.e. not a complete whole number of bytes)
ToBase16(byte[])
Converts the array to a Base16 (hex) representation
public static string ToBase16(byte[] data)
Parameters
data
byte[]The data to convert
Returns
- string
The Base16 equivalent of the data
ToBase16(byte[], int, int)
Converts the array to a Base16 (hex) representation
public static string ToBase16(byte[] data, int offset, int length)
Parameters
data
byte[]The data to convert
offset
intThe offset into the array to convert from
length
intThe number of bytes to convert
Returns
- string
The Base16 equivalent of the data
TryParse(string, out byte[])
Attempt to parse hex as a hex string (white-space allowed). Return the result as a byte array
public static bool TryParse(string hex, out byte[] result)
Parameters
Returns
- bool
True if the hex was parse successfully. False otherwise
TryParse(string, out byte[], out string)
Attempt to parse hex as a hex string (white-space allowed). Return the result as a byte array
public static bool TryParse(string hex, out byte[] result, out string errorMessage)
Parameters
hex
stringThe hex string to parse
result
byte[]The hex as a byte array
errorMessage
stringA human readable message explaining the parse error
Returns
- bool
True if the hex was parse successfully. False otherwise