Class BufferTools
This class is used to maintain utility functions to handle buffers.
Inheritance
Inherited Members
Namespace: Westpay.Epas
Assembly: EpasClientLibrary.dll
Syntax
public static class BufferTools
Methods
View SourceByteArrayToHexString(Byte[], Int32, Int32)
Converts a byte array (for example 0xA0, 0x34, 0x05, 0xBF, 0x22, 0x02, 0xE1) to a hex string ("A03405BF2202E1")
Declaration
public static string ByteArrayToHexString(byte[] src, int start = 0, int length = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | src | Byte array to convert |
System.Int32 | start | Start point in the byte array (default 0) |
System.Int32 | length | Number of bytes to convert (defaults to the whole array) |
Returns
Type | Description |
---|---|
System.String | The string containing the hex representation of the array contents, or null if an error occurred |
HexStringToByteArray(String, Int32, Int32)
Converts a hex string (for example "A03405BF2202E1") to a byte array {0xA0, 0x34, 0x05, 0xBF, 0x22, 0x02, 0xE1}
Declaration
public static byte[] HexStringToByteArray(string src, int start = 0, int length = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | src | Hex string containing the data to convert |
System.Int32 | start | Start point in the string (default 0) |
System.Int32 | length | Length of the string to convert (defaults to the whole string) |
Returns
Type | Description |
---|---|
System.Byte[] | Byte array containing the parsed data, or null if the conversion fails |
StringToByteArray(String, out Byte[], Int32, Int32, Int32)
Converts a numeric string to a byte array. This can be in hex, for example "A03405BF2202E1" to {0xA0, 0x34, 0x05, 0xBF, 0x22, 0x02, 0xE1} or it can be decimal, for example "304980120183" to {30, 49, 80, 12, 01, 83}
Declaration
public static bool StringToByteArray(string src, out byte[] result, int start = 0, int length = 0, int numberBase = 16)
Parameters
Type | Name | Description |
---|---|---|
System.String | src | Hex string containing the data to convert |
System.Byte[] | result | Byte array containing the parsed data, if successful |
System.Int32 | start | Start point in the string (default 0) |
System.Int32 | length | Length of the string to convert (defaults to the whole string) |
System.Int32 | numberBase | Base of the number encoding in the string. Use 16 to decode hex, 10 to decode decimal. Default is 16. |
Returns
Type | Description |
---|---|
System.Boolean | True on success, false otherwise |