ToBytes

public static byte[] ToBytes(this string content)
        {
            byte[] bytes = new byte[content.Length * sizeof(char)];
            System.Buffer.BlockCopy(content.ToCharArray(), 0, bytes, 0, bytes.Length);
            return bytes;           
        }
Example:
string test="hello world";
btye[] bytes=test.ToBytes();

Description

Convert a string to a byte array

Details

Double click on the code to select all.

 

;