您的位置:首页 > 编程语言 > C#

c#中文gbk编码查询示例代码

2018-10-12 14:07 411 查看


private void button_Inquriy_Click(object sender, EventArgs e)
 {
     if (textBox_Inquiry.TextLength > 0)
     {
         String strInquiry = textBox_Inquiry.Text;
         byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(strInquiry);
         String strResult = String.Empty;
         foreach (byte b in bytes)
         {
             strResult += b.ToString("X2");
             strResult += " ";
         }
         textBox_Result.Text = strResult;
     }
     else
     {
         MessageBox.Show("请输入待查询的字符");
     }
 }

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: