EncodingGetBytes Method (Char, Int32, Byte, Int32) |
When overridden in a derived class, encodes a set of characters starting at the specified character pointer into a sequence of bytes that are stored starting at the specified byte pointer.
Namespace: System.TextAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public virtual int GetBytes(
char* chars,
int charCount,
byte* bytes,
int byteCount
)
Parameters
- chars
- Type: SystemChar*
A pointer to the first character to encode. - charCount
- Type: SystemInt32
The number of characters to encode. - bytes
- Type: SystemByte*
A pointer to the location at which to start writing the resulting sequence of bytes. - byteCount
- Type: SystemInt32
The maximum number of bytes to write.
Return Value
Type:
Int32The actual number of bytes written at the location indicated by the
bytes parameter.
Exceptions Exception | Condition |
---|
ArgumentNullException | chars is null.-or- bytes is null. |
ArgumentOutOfRangeException | charCount or byteCount is less than zero. |
ArgumentException | byteCount is less than the resulting number of bytes. |
EncoderFallbackException | A fallback occurred (see Character Encoding in the .NET Framework for complete explanation)-and-EncoderFallback is set to EncoderExceptionFallback. |
See Also