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.TextAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax 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:
Int32The actual number of bytes written into
bytes.
Exceptions Exception | Condition |
---|
ArgumentNullException | s is null.-or- bytes is null. |
ArgumentOutOfRangeException | charIndex 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. |
ArgumentException | bytes does not have enough capacity from byteIndex to the end of the array to accommodate the resulting bytes. |
EncoderFallbackException | A fallback occurred (see Character Encoding in the .NET Framework for complete explanation)-and-EncoderFallback is set to EncoderExceptionFallback. |
See Also