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);
}
}
}
}
获取字母的ASCII码
最新推荐文章于 2024-01-05 09:51:40 发布