When overridden in a derived class, returns the number of characters required to decode a range of an array of bytes.
[Visual Basic] Overloads MustOverride Public Function GetCharCount( _ ByVal bytes() As Byte, _ ByVal index As Integer, _ ByVal count As Integer _ ) As Integer [C#] public abstract int GetCharCount( byte[] bytes, int index, int count ); [C++] public: virtual int GetCharCount( unsigned char* bytes[], int index, int count ) = 0; [JScript] public abstract function GetCharCount( bytes : Byte[], index : int, count : int ) : int;
The number of characters produced by decoding a range of bytes in the specified byte array.
Exception Type | Condition |
---|---|
ArgumentNullException | bytes is a null reference (in Visual Basic Nothing). |
ArgumentOutOfRangeException | index and count do not denote a valid range in the byte array. |
The GetCharCount method can be used to determine the exact the number of characters that will be produces from converting a given range of bytes. An appropriately sized buffer for that conversion can then be allocated. Alternatively, the GetMaxCharCount method can be used to determine the maximum number of characters that will produced for a given number of bytes. A buffer of that size can then be reused for multiple conversions. GetCharCount method generally uses less memory and GetMaxCharCount generally executes faster.
Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetCharCount Overload List