System.StringHelper.GetBytes C# (CSharp) Method

GetBytes() public static method

字符串转数组
public static GetBytes ( String value, System.Encoding encoding = null ) : Byte[]
value String 字符串
encoding System.Encoding 编码,默认utf-8无BOM
return Byte[]
        public static Byte[] GetBytes(this String value, Encoding encoding = null)
        {
            if (value == null) return null;
            if (value == String.Empty) return new Byte[0];

            if (encoding == null) encoding = Encoding.UTF8;
            return encoding.GetBytes(value);
        }