首页 > 技术文章 > ASCII十进制转字符串的方法

vice 2017-07-18 12:24 原文

        /// <summary>
        /// ASCII转字符串
        /// </summary>
        /// <param name="asciiCode">ASCII对应十进制码</param>
        /// <returns></returns>
        public static string ASCIIToStr(int asciiCode)
        {
            if (asciiCode >= 0 && asciiCode <= 255)
            {
                System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                byte[] byteArray = new byte[] { (byte)asciiCode };
                string strCharacter = asciiEncoding.GetString(byteArray);
                return (strCharacter);
            }
            else
            {
                throw new Exception("ASCII Code is not valid.");
            }
        }

  

推荐阅读