0
点赞
收藏
分享

微信扫一扫

获取字母的ASCII码





using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;



namespace Ex04_01

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}



private void button1_Click(object sender, EventArgs e)

{

if (textBox1.Text == "")

{

MessageBox.Show("字母文本框不能为空", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);

textBox1.Focus();

}

else

{

byte[] array = new byte[1];

array = System.Text.Encoding.ASCII.GetBytes(textBox1.Text.Trim());

int asciicode = (short)(array[0]);

textBox2.Text = Convert.ToString(asciicode);

 


 


 

举报

相关推荐

0 条评论