字符串转ASCCI码

  /// <summary>
        /// string转ascci码
        /// </summary>
        /// <param name="asciiCode"></param>
        /// <returns></returns>
        public byte[] Asc(string readStr)
        {
            try
            {
                byte[] asciiByte = new byte[readStr.Length];
                if (readStr.Length == 0)
                {
                    return null;
                }
                else
                {
                    System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                    asciiByte = asciiEncoding.GetBytes(readStr);
                    return (asciiByte);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        } 
原文地址:https://www.cnblogs.com/Iyce/p/2852929.html