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

System.Text.UTF8Encoding.GetByteCount Method

Determines the number of bytes required to encode the specified range of characters in the specified Unicode character array as a System.Text.UTF8Encoding.

public override int GetByteCount (char[] chars, int index, int count)

Parameters

chars
The char array to encode as a System.Text.UTF8Encoding .
index
A int that specifies the first index of chars to encode.
count
A int that specifies the number of characters to encode.

Returns

A int containing the number of bytes necessary to encode the range in chars from index to index + count - 1 as a System.Text.UTF8Encoding.

Exceptions

TypeReason
ArgumentNullExceptionchars is null .
ArgumentOutOfRangeException

The return value is greater than int.MaxValue.

-or-

index or count is less than zero.

-or-

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

ArgumentExceptionError-checking is turned on for the current instance and chars contains an invalid surrogate sequence.

Remarks

If error-checking is turned off and an invalid surrogate sequence is detected, the invalid characters are ignored and do not affect the return value, and no exception is thrown.

Note:

This method overrides Encoder.GetByteCount(Char[], int, int, bool) .

Requirements

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