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.GetByteCount (Char[], Int32, Int32)

When overridden in a derived class, returns the number of bytes required to encode a range of characters in the specified character array.

[Visual Basic]
Overloads MustOverride Public Function GetByteCount( _
   ByVal chars() As Char, _
   ByVal index As Integer, _
   ByVal count As Integer _
) As Integer
[C#]
public abstract int GetByteCount(
   char[] chars,
   int index,
   int count
);
[C++]
public: virtual int GetByteCount(
   __wchar_t* chars[],
   int index,
   int count
) = 0;
[JScript]
public abstract function GetByteCount(
   chars : Char[],
   index : int,
   count : int
) : int;

Parameters

chars
The character array to encode.
index
The starting index of the character array to encode.
count
The number of characters to encode.

Return Value

The number of bytes required to encode a range of characters in the specified character array.

Exceptions

Exception Type Condition
ArgumentNullException chars is a null reference (in Visual Basic Nothing).
ArgumentOutOfRangeException index and count do not denote a valid range in the character array.

Remarks

The GetByteCount method can be used to determine the exact the number of bytes that will be produced from converting a given range of characters. An appropriately sized buffer for that conversion can then be allocated. Alternatively, the GetMaxByteCount method can be used to determine the maximum number of bytes that will be produced from converting a given number of characters. A buffer of that size can then be reused for multiple conversions. GetByteCount method generally uses less memory and GetMaxByteCount generally executes faster.

See Also

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