GetBytes Method (String)

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()
[C#]
public virtual byte[] GetBytes(
 string s
);
[C++]
public: virtual unsigned char GetBytes(
 String* s
)  __gc[];
[JScript]
public function GetBytes(
   s : String
) : Byte[];

Parameters

s
The String to encode.

Return Value

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

Exceptions

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

Remarks

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

Requirements

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

Show:
© 2016 Microsoft