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

    实现效果:

    关键知识:

    实现代码:

     1     private void button1_Click(object sender, EventArgs e)
     2     {
     3         if (textBox1.Text != string.Empty) {//不为空
     4             if (Encoding.GetEncoding("unicode").//判断字是否为字符
     5                 GetBytes(new char[] { textBox1.Text[0] })[1] == 0)
     6             {       //转ASCII
     7                 textBox2.Text = Encoding.GetEncoding("unicode").
     8                     GetBytes(textBox1.Text)[0].ToString(); 
     9             }
    10             else {
    11                 textBox1.Text = string.Empty;
    12                 MessageBox.Show("请输入正确字母");
    13             }
    14         }
    15     }
    16     private void button2_Click(object sender, EventArgs e)
    17     {
    18         if (textBox3.Text != string.Empty) { 
    19             int temp;
    20             if (int.TryParse(textBox3.Text, out temp))
    21             {   //转换字符
    22                 textBox4.Text = ((char)temp).ToString();
    23             }
    24             else {
    25                 textBox1.Text = string.Empty;
    26                 MessageBox.Show("请输入正确数字");
    27             }
    28         }
    29     }
  • 相关阅读:
    c# 并行运算二
    c# 并行运算
    Task+http请求
    Task多线程
    SSO系统认证
    web系统权限设计
    AutoMapper的使用
    中间件
    express-middleware
    中间件概念
  • 原文地址:https://www.cnblogs.com/feiyucha/p/9893467.html
Copyright © 2011-2022 走看看