Mono Class Library: System.Text.Encoder Overview | Members

System.Text.Encoder.GetByteCount Method

Determines the exact number of bytes required to encode the specified range in the specified array of characters.

public abstract int GetByteCount (char[] chars, int index, int count, bool flush)

Parameters

chars
A char array of characters to encode.
index
A int that specifies the first index of chars to encode.
count
A int that specifies the number of elements in chars to encode.
flush
A bool value that determines whether the current instance flushes its internal state following a conversion. Specify true to flush the internal state of the current instance following a conversion; otherwise, specify false .

Returns

A int containing the number of bytes required to encode the range in chars from index to index + count -1 for a particular encoding.

Note: This value takes into account the state in which the current instance was left following the last call to Encoder.GetBytes(Char[], int, int, Byte[], int, bool) .

Exceptions

TypeReason
ArgumentNullExceptionchars is null.
ArgumentOutOfRangeException

Return value is greater than int.MaxValue.

-or-

index < 0.

-or-

count < 0.

-or-

index and count do not specify a valid range in chars (i.e. (index + count) > chars.Length).

Remarks

The state of the current instance is not affected by a call to this method.

Operation
As described above.

Note to Inheritors
Override this method to retrieve the exact number of bytes required to encode a specified range of an array of char objects for a particular encoding.

Usage
Use this method to determine the exact number of bytes required to encode the specified range of an array of char objects for a particular encoding.

Requirements

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0