C#利用微软自带库进行中文繁体和简体之间的转换的代码

做工程之余,将做工程过程比较重要的代码备份一次,如下资料是关于C#利用微软自带库进行中文繁体和简体之间的转换的代码,应该是对码农有所帮助。

 protected void Button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txt_value.Text))
     {
         return;
     }
     else
     {
         string value = txt_value.Text.Trim();
         string newValue = StringConvert(value, "1");
         if (!string.IsNullOrEmpty(newValue))
         {
             TextArea1.Value = newValue;
         }
     }
 }
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txt_value.Text))
     {
         return;
     }
     else
     {
         string value = txt_value.Text.Trim();
         string newValue = StringConvert(value, "2");
         if (!string.IsNullOrEmpty(newValue))
         {
             TextArea1.Value = newValue;
         }
     }
 }

 #region IString 成员

 public string StringConvert(string x, string type)
 {
     String value = String.Empty;
     switch (type)
     {
             value =  Microsoft.VisualBasic.Strings.StrConv(x, Microsoft.VisualBasic.VbStrConv.TraditionalChinese,0);
             break;
         case "2":
             value = Microsoft.VisualBasic.Strings.StrConv(x, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, 0);
             break;
         default:
             break;
     }
     return value;
 }

 #endregion

转载于:https://blog.51cto.com/14143192/2369740

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值