private void btnOk_Click(object sender, EventArgs e) { try { char chrWord = Convert.ToChar(txtWord.Text); //获取一个汉字 byte[] gb2312 = Encoding.GetEncoding("GB2312").GetBytes( new char[] { chrWord }); //获得编码字节序列 int n = (int)gb2312[0] << 8; //第一个字节序列左移8位 n += (int)gb2312[1]; //得到汉字编码 txtCode.Text = n.ToString(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }