This documentation is archived and is not being maintained.

Encoding.GetBytes Method (String)

.NET Framework 1.1

Encodes a specified String into an array of bytes.

[Visual Basic]
Overloads Public Overridable Function GetBytes( _
   ByVal s As String _
) As Byte()
public virtual byte[] GetBytes(
 string s
public: virtual unsigned char GetBytes(
 String* s
)  __gc[];
public function GetBytes(
   s : String
) : Byte[];


The String to encode.

Return Value

A byte array containing the encoded representation of the specified string.


Exception Type Condition
ArgumentNullException s is a null reference (Nothing in Visual Basic).


The GetBytes method maintains no state between conversions. The method is intended for conversion of a complete block of characters in one operation.


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