如何转换双字节字符串单字节字符串? [英] How to Convert Double Byte String to Single Byte String?

查看:500
本文介绍了如何转换双字节字符串单字节字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中的新手。结果
我有一个文本框,并允许它接受 double_byte 字符串,并将其用于输入/显示的日期值即可。
现在我有一个问题,我不知道如何解决this.I GOOGLE了一下,并不能找到它的任何解决方案。结果
当我写了 Double_Byte 字符( 2012年12月31日),我想在<$这个值更改为( 2012年12月31日) C $ C> Leave_Event 文本框或 Text_Changed 这个文本框的事件。所以,我怎样才能解决这个问题搜索结果
修改 - >我的解决办法是窗口应用 -



先谢谢了。


解决方案

感谢您对所有的答案和利益。结果
我寻找一个解决方案,并没有发现任何回答。最后,我从我的同事一个很好的答案。
因此,我赞同这个问题的答案。结果




  1. 添加引用Microsoft.VisualBasic程序

  2. 写这样的代码(如 sa_ddam213的回答测试) - 结果



  
使用Microsoft.VisualBasic程序;

私人无效的button1_Click(对象发件人,EventArgs五)
{
串的inputText = textBox1.Text;
串singleByteString = Strings.StrConv(inputText的,VbStrConv.Narrow,0);

textBox2.Text = singleByteString;
textBox3.Text = inputText的;
}


I am a newbie at C#.
I have a Textbox and it is allowed to accept double_byte string and it is used to input/show Date Value. Now I am having a problem and I don't know how to solve this.I googled about it,and can't find any solution for it.
When I wrote Double_Byte Characters( 2012/12/31) ,I want to change this value to (2012/12/31) at Leave_Event of TextBox or Text_Changed Event of this TextBox. So, How can I solve the problem.

Edit->My Solution is Window Application.

Thanks in advance.

解决方案

Thank you for all of your answers and interests.
I searched a solution for this and not found any answer .Finally ,I got a nice answer from my colleague. Therefore, I share the answer of this problem.

  1. Add Reference Microsoft.VisualBasic
  2. write code like this(test like sa_ddam213's answer)-


using Microsoft.VisualBasic;

private void button1_Click(object sender, EventArgs e)
{
      string inputText = textBox1.Text;
      string singleByteString =  Strings.StrConv(inputText, VbStrConv.Narrow, 0);

      textBox2.Text = singleByteString;
      textBox3.Text = inputText;
}

这篇关于如何转换双字节字符串单字节字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆