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

System.Text.UTF8Encoding.GetByteCount Method

Determines the number of bytes required to encode the characters in the specified string as a System.Text.UTF8Encoding.

public override int GetByteCount (string chars)

Parameters

chars
A string to encode as a System.Text.UTF8Encoding.

Returns

A int that specifies the number of bytes necessary to encode chars as a System.Text.UTF8Encoding.

Exceptions

TypeReason
ArgumentNullExceptionchars is null.
ArgumentExceptionError-checking is turned on for the current instance and chars contains an invalid surrogate sequence.
ArgumentOutOfRangeExceptionThe return value is greater than int.MaxValue.

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

Requirements

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