zoukankan      html  css  js  c++  java
  • C# ASCII 转字符 字符 转 ASCII

    public static int Asc(string character)
      {
       if (character.Length == 1)
       {
        System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
        int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0];
        return (intAsciiCode);
       }
       else
       {
        throw new Exception("无效的字符或字符太长");
       }
    
      }
    
    public static string Chr(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码");
       }
      }
  • 相关阅读:
    Demo
    Demo
    z-yelir-~
    CSP考前总结
    NOIP刷题
    清北学堂
    qsing
    【csp模拟赛九】--dfs3
    【csp模拟赛九】--dfs2
    【csp模拟赛九】--dfs
  • 原文地址:https://www.cnblogs.com/jcdd-4041/p/4228380.html
Copyright © 2011-2022 走看看