Encoding.GetBytes Method (Char[], Int32, Int32) |
When overridden in a derived class, encodes a set of characters from the specified character array into a sequence of bytes.
Namespace: System.TextAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public virtual byte[] GetBytes(
char[] chars,
int index,
int count
)
Parameters
- chars
- Type:System.Char[]
The character array containing the set of characters to encode. - index
- Type: System.Int32
The index of the first character to encode. - count
- Type: System.Int32
The number of characters to encode.
Return Value
Type:
Byte[]A byte array containing the results of encoding the specified set of characters.
Exceptions Exception | Condition |
---|
ArgumentNullException | chars is null. |
ArgumentOutOfRangeException | index or count is less than zero.-or- index and count do not denote a valid range in chars. |
EncoderFallbackException | A fallback occurred (see Character Encoding in the .NET Framework for complete explanation)-and-EncoderFallback is set to EncoderExceptionFallback. |
See Also