Get Bytes from String - CSharp System

CSharp examples for System:String Format

Description

Get Bytes from String

Demo Code


using System;//from   w  w w . j  a  va2  s  .  c  om

public class Main{
        public static byte[] GetBytes(string st)
        {
            var bytes = new byte[st.Length * sizeof(char)];
            System.Buffer.BlockCopy(st.ToCharArray(), 0, bytes, 0, st.Length);
            return bytes;
        }
}

Related Tutorials