字符串转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;
            }

        } 

 

posted on 2013-01-09 14:37  酒歌  阅读(239)  评论(0编辑  收藏  举报