c#字母与ASCLL码的转换

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace 字母与ASCLL码的转换
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            groupBox1.Text = "字母与ASCLL码的转换";
            button1.Text = "转换为ASCLL码";
            button2.Text = "转换为字母";
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if(textBox1.Text==" ")
            {
                MessageBox.Show("请输入需要转换的字母");
            }
            Encoding P_encod = Encoding.GetEncoding("unicode");
            byte[] P_byte=P_encod.GetBytes(textBox1.Text);
            textBox3.Text = P_byte[0].ToString();
            
        }


        private void button2_Click(object sender, EventArgs e)
        {
            int P_num;
            if (textBox2.Text == " ")
            {
                MessageBox.Show("请输入需要转换的数");
            }
            if(int.TryParse(textBox2.Text,out P_num))
            {
                textBox4.Text = ((char)P_num).ToString(); 
            }
        }
    }
}

encoding中文意思是编码,那在c#中必定是用来编码转换的

在这个程序中用到了encoding对象的GetEncoding方法

运行图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

锡城筱凯

你的鼓励是我创造的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值