c#中文gbk编码查询示例代码
程序员文章站
2024-03-31 10:43:58
复制代码 代码如下:private void button_inquriy_click(object sender, eventargs e) { &n...
复制代码 代码如下:
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("请输入待查询的字符");
}
}