码迷,mamicode.com
首页 > 其他好文 > 详细

ASCII十进制转字符串的方法

时间:2017-07-18 13:21:22      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:sharp   sha   val   class   csharp   log   int   pre   asc   

        /// <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.");
            }
        }

  

ASCII十进制转字符串的方法

标签:sharp   sha   val   class   csharp   log   int   pre   asc   

原文地址:http://www.cnblogs.com/vice/p/7199863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!