Encodes a specified string into an array of bytes with no specified range.
[Visual Basic] Overloads Overridable Public Function GetBytes( _ ByVal s As String _ ) As Byte () [C#] public virtual byte[] GetBytes( string s ); [C++] public: virtual unsigned char* GetBytes( String* s ) []; [JScript] public function GetBytes( s : String ) : Byte[];
An array of type Byte containing the encoded representation of the specified string.
Exception Type | Condition |
---|---|
ArgumentNullException | s is a null reference (in Visual Basic Nothing). |
The GetBytes method maintains no state between conversions. The method is intended for conversions of complete blocks of bytes and characters in one operation. The GetBytes method requires the caller to provide the destination buffer and ensure that the buffer is large enough to hold the entire result of the conversion. When using this method directly on an Encoding object or on an associated Decoder or Encoder, an application can use GetByteCount or GetMaxByteCount to allocate destination buffers.
Encoding Class | Encoding Members | System.Text Namespace | Encoding.GetBytes Overload List | GetByteCount | GetMaxByteCount | GetDecoder | GetEncoder