当前位置:主页 > 软件编程 > .NET代码 >

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

时间:2021-05-18 09:42:58 | 栏目:.NET代码 | 点击:

复制代码 代码如下:

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("请输入待查询的字符");
     }
 }

您可能感兴趣的文章:

相关文章