Class HexEncoding
Summary description for HexEncoding. http://www.codeproject.com/KB/recipes/hexencoding.aspx
public class HexEncoding : Encoding, ICloneable- Inheritance
- 
      
      
      HexEncoding
- Implements
- Inherited Members
- Extension Methods
Constructors
HexEncoding()
public HexEncoding()Methods
GetByteCount(char[], int, int)
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified character array.
public override int GetByteCount(char[] chars, int index, int count)Parameters
- charschar[]
- The character array containing the set of characters to encode. 
- indexint
- The index of the first character to encode. 
- countint
- The number of characters to encode. 
Returns
- int
- The number of bytes produced by encoding the specified characters. 
Exceptions
- ArgumentNullException
- charsis null.
- ArgumentOutOfRangeException
- indexor- countis less than zero. -or-- indexand- countdo not denote a valid range in- chars.
- EncoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- EncoderFallback is set to EncoderExceptionFallback. 
GetByteCount(string)
When overridden in a derived class, calculates the number of bytes produced by encoding the characters in the specified string.
public override int GetByteCount(string hexString)Parameters
Returns
- int
- The number of bytes produced by encoding the specified characters. 
Exceptions
- ArgumentNullException
- hexStringis null.
- EncoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- EncoderFallback is set to EncoderExceptionFallback. 
GetBytes(char[], int, int, byte[], int)
When overridden in a derived class, encodes a set of characters from the specified character array into the specified byte array.
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)Parameters
- charschar[]
- The character array containing the set of characters to encode. 
- charIndexint
- The index of the first character to encode. 
- charCountint
- The number of characters to encode. 
- bytesbyte[]
- The byte array to contain the resulting sequence of bytes. 
- byteIndexint
- The index at which to start writing the resulting sequence of bytes. 
Returns
- int
- The actual number of bytes written into - bytes.
Exceptions
- ArgumentNullException
- charsis null. -or-- bytesis null.
- ArgumentOutOfRangeException
- charIndexor- charCountor- byteIndexis less than zero. -or-- charIndexand- charCountdo not denote a valid range in- chars. -or-- byteIndexis not a valid index in- bytes.
- ArgumentException
- bytesdoes not have enough capacity from- byteIndexto the end of the array to accommodate the resulting bytes.
- EncoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- EncoderFallback is set to EncoderExceptionFallback. 
GetBytes(char[], int, int, out int)
Creates a byte array from the hexadecimal string. Each two characters are combined to create one byte. First two hexadecimal characters become first byte in returned array. Non-hexadecimal characters are ignored.
public static byte[] GetBytes(char[] chars, int charIndex, int charCount, out int discarded)Parameters
- charschar[]
- The character array containing the set of characters to encode. 
- charIndexint
- The index of the first character to encode. 
- charCountint
- The number of characters to encode. 
- discardedint
- number of characters in string ignored. 
Returns
- byte[]
- byte array, in the same left-to-right order as the hexString. 
GetBytes(string)
Creates a byte array from the hexadecimal string. Each two characters are combined to create one byte. First two hexadecimal characters become first byte in returned array. Non-hexadecimal characters are ignored.
public override byte[] GetBytes(string hexString)Parameters
- hexStringstring
- string to convert to byte array 
Returns
- byte[]
- byte array, in the same left-to-right order as the hexString 
GetCharCount(byte[], int, int)
When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
public override int GetCharCount(byte[] bytes, int index, int count)Parameters
- bytesbyte[]
- The byte array containing the sequence of bytes to decode. 
- indexint
- The index of the first byte to decode. 
- countint
- The number of bytes to decode. 
Returns
- int
- The number of characters produced by decoding the specified sequence of bytes. 
Exceptions
- ArgumentNullException
- bytesis null.
- ArgumentOutOfRangeException
- indexor- countis less than zero. -or-- indexand- countdo not denote a valid range in- bytes.
- DecoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- DecoderFallback is set to DecoderExceptionFallback. 
GetChars(byte[], int, int, char[], int)
When overridden in a derived class, decodes a sequence of bytes from the specified byte array into the specified character array.
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)Parameters
- bytesbyte[]
- The byte array containing the sequence of bytes to decode. 
- byteIndexint
- The index of the first byte to decode. 
- byteCountint
- The number of bytes to decode. 
- charschar[]
- The character array to contain the resulting set of characters. 
- charIndexint
- The index at which to start writing the resulting set of characters. 
Returns
- int
- The actual number of characters written into - chars.
Exceptions
- ArgumentNullException
- bytesis null. -or-- charsis null.
- ArgumentOutOfRangeException
- byteIndexor- byteCountor- charIndexis less than zero. -or-- byteIndexand- byteCountdo not denote a valid range in- bytes. -or-- charIndexis not a valid index in- chars.
- ArgumentException
- charsdoes not have enough capacity from- charIndexto the end of the array to accommodate the resulting characters.
- DecoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- DecoderFallback is set to DecoderExceptionFallback. 
GetMaxByteCount(int)
When overridden in a derived class, calculates the maximum number of bytes produced by encoding the specified number of characters.
public override int GetMaxByteCount(int charCount)Parameters
- charCountint
- The number of characters to encode. 
Returns
- int
- The maximum number of bytes produced by encoding the specified number of characters. 
Exceptions
- ArgumentOutOfRangeException
- charCountis less than zero.
- EncoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- EncoderFallback is set to EncoderExceptionFallback. 
GetMaxCharCount(int)
When overridden in a derived class, calculates the maximum number of characters produced by decoding the specified number of bytes.
public override int GetMaxCharCount(int byteCount)Parameters
- byteCountint
- The number of bytes to decode. 
Returns
- int
- The maximum number of characters produced by decoding the specified number of bytes. 
Exceptions
- ArgumentOutOfRangeException
- byteCountis less than zero.
- DecoderFallbackException
- A fallback occurred (see Understanding Encodings for complete explanation) -and- DecoderFallback is set to DecoderExceptionFallback. 
IsHexDigit(char)
Returns true is c is a hexadecimal digit (A-F, a-f, 0-9)
public static bool IsHexDigit(char c)Parameters
- cchar
- Character to test. 
Returns
- bool
- true if hex digit, false if not.