NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Encoding.GetCharCount (Byte[], Int32, Int32)

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;

Parameters

bytes
The byte array to decode.
index
The starting index where decoding begins.
count
The number of bytes to decode.

Return Value

The number of characters produced by decoding a range of bytes in the specified byte array.

Exceptions

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.

Remarks

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.

See Also

Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetCharCount Overload List