This documentation is archived and is not being maintained.

Encoding.GetBytes Method (Char[], Int32, Int32)

.NET Framework 1.1

Encodes a range of characters from a character array into a byte array.

[Visual Basic]
Overloads Public Overridable Function GetBytes( _
   ByVal chars() As Char, _
   ByVal index As Integer, _
   ByVal count As Integer _
) As Byte()
public virtual byte[] GetBytes(
 char[] chars,
 int index,
 int count
public: virtual unsigned char GetBytes(
 __wchar_t chars __gc[],
 int index,
 int count
)  __gc[];
public function GetBytes(
   chars : Char[],
 index : int,
 count : int
) : Byte[];


The character array to encode.
The starting index of the character array to encode.
The number of characters to encode.

Return Value

A byte array containing the encoded representation of the specified range of characters in chars.


Exception Type Condition
ArgumentNullException chars is a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeException The index and count parameters do not denote a valid range in chars.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetBytes Overload List | GetByteCount | GetMaxByteCount | GetDecoder | GetEncoder