zoukankan      html  css  js  c++  java
  • C# ASCII码和英文字母相互转换和ASCII码对照表

    1、字母转换成ASCII码

     1             string str = "hello";
     2             byte[] array = new byte[1];  
     3             array = System.Text.Encoding.ASCII.GetBytes(str); //把str的每个字符转换成ascii码
     4 
     5             int asciicode1 = (short)(array[0]);//h 的ascii码
     6             int asciicode2 = (short)(array[1]);//e 的ascii码
     7             int asciicode3 = (short)(array[2]);//l 的ascii码
     8             int asciicode4 = (short)(array[3]);//l 的ascii码
     9             int asciicode5 = (short)(array[4]);//o 的ascii码
    10 
    11             int asciicode = 0;
    12             for (int i = 0; i < array.Length; i++)
    13             {
    14                 asciicode += array[i];//str 的ascii码
    15             }

    2、ASCII码换成字母

    1 byte[] array = new byte[1];
    2 array[0] = (byte)(Convert.ToInt32(104));//ASCII码强制转换二进制
    3 string ret=Convert.ToString(System.Text.Encoding.ASCII.GetString(array));

    3、ASCII码对照表

  • 相关阅读:
    【leetcode】1230.Toss Strange Coins
    2018.12.25 SOW
    L203 词汇题
    L202
    L201
    L200
    2018
    2018.12.21 Cmos- RF
    L198
    L196 Hospital educations
  • 原文地址:https://www.cnblogs.com/ElvisZhongShao/p/8534546.html
Copyright © 2011-2022 走看看