Click or drag to resize
EncodingGetBytes Method (String, Int32, Int32, Byte, Int32)
When overridden in a derived class, encodes a set of characters from the specified string into the specified byte array.

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public virtual int GetBytes(
	string s,
	int charIndex,
	int charCount,
	byte[] bytes,
	int byteIndex
)

Parameters

s
Type: SystemString
The string containing the set of characters to encode.
charIndex
Type: SystemInt32
The index of the first character to encode.
charCount
Type: SystemInt32
The number of characters to encode.
bytes
Type: SystemByte
The byte array to contain the resulting sequence of bytes.
byteIndex
Type: SystemInt32
The index at which to start writing the resulting sequence of bytes.

Return Value

Type: Int32
The actual number of bytes written into bytes.
Exceptions
ExceptionCondition
ArgumentNullExceptions is null.-or- bytes is null.
ArgumentOutOfRangeExceptioncharIndex or charCount or byteIndex is less than zero.-or- charIndex and charCount do not denote a valid range in chars.-or- byteIndex is not a valid index in bytes.
ArgumentExceptionbytes does not have enough capacity from byteIndex to the end of the array to accommodate the resulting bytes.
EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for complete explanation)-and-EncoderFallback is set to EncoderExceptionFallback.
See Also