C#利用微软自带库进行中文繁体和简体之间转换的方法
2015-04-01 15:03
821 查看
本文实例讲述了C#利用微软自带库进行中文繁体和简体之间转换的方法。分享给大家供大家参考。具体分析如下:
下面的代码是一个简单的转换范例,真正的核心转换语句只有一句话,其它的都是界面和数据相关的,使用前需要引用Microsoft.VisualBasic这个类库
/// <summary> /// 转繁体 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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; } } } /// <summary> /// 转简体 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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) { case "1"://转繁体 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
希望本文所述对大家的C#程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- C#自定义繁体和简体字库实现中文繁体和简体之间转换的方法
- php中文繁体和简体相互转换的方法
- C#实现简体繁体之间转换
- C#实现简体中文和繁体中文的转换
- 简体中文和繁体中文转换方法
- VB.net c# 简体繁体之间的转换
- C#中文繁简之间的转换的方法
- c# 简体繁体之间的转换
- 中文简体繁体之间的转换
- C#中汉字的繁体和简体的相互转换的两个方法!
- C#中汉字的繁体和简体的相互转换的方法
- C#实现简体中文和繁体中文的转换
- C# 简体中文转换为繁体中文
- 繁体中文转换为简体中文的PHP函数
- 简体中文转换为繁体中文的PHP函数
- js 实现繁体和简体之间的转换
- 简体中文与繁体中文之间的转换
- C# IP地址与整数之间转换的具体方法
- 繁体与简体之间的转换
- C#中对日期格式进行转换的方法