[C#] C#利用微软自带库进行中文繁体和简体之间的转换 →→→→→进入此内容的聊天室

来自 , 2019-05-02, 写在 C#, 查看 99 次.
URL http://www.code666.cn/view/14553eed
  1.  /// <summary>
  2.  /// 转繁体
  3.  /// </summary>
  4.  /// <param name="sender"></param>
  5.  /// <param name="e"></param>
  6.      protected void Button1_Click(object sender, EventArgs e)
  7.      {
  8.          if (string.IsNullOrEmpty(txt_value.Text))
  9.          {
  10.              return;
  11.          }
  12.          else
  13.          {
  14.              string value = txt_value.Text.Trim();
  15.              string newValue = StringConvert(value, "1");
  16.              if (!string.IsNullOrEmpty(newValue))
  17.              {
  18.                  TextArea1.Value = newValue;
  19.              }
  20.          }
  21.      }
  22.      /// <summary>
  23.  /// 转简体
  24.  /// </summary>
  25.  /// <param name="sender"></param>
  26.  /// <param name="e"></param>
  27.      protected void Button2_Click(object sender, EventArgs e)
  28.      {
  29.          if (string.IsNullOrEmpty(txt_value.Text))
  30.          {
  31.              return;
  32.          }
  33.          else
  34.          {
  35.              string value = txt_value.Text.Trim();
  36.              string newValue = StringConvert(value, "2");
  37.              if (!string.IsNullOrEmpty(newValue))
  38.              {
  39.                  TextArea1.Value = newValue;
  40.              }
  41.          }
  42.      }
  43.  
  44.      #region IString 成员
  45.  
  46.      public string StringConvert(string x, string type)
  47.      {
  48.          String value = String.Empty;
  49.          switch (type)
  50.          {
  51.              case "1"://转繁体
  52.                  value =  Microsoft.VisualBasic.Strings.StrConv(x, Microsoft.VisualBasic.VbStrConv.TraditionalChinese,0);
  53.                  break;
  54.              case "2":
  55.                  value = Microsoft.VisualBasic.Strings.StrConv(x, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, 0);
  56.                  break;
  57.              default:
  58.                  break;
  59.          }
  60.          return value;
  61.      }
  62.  
  63.      #endregion
  64. //csharp/7803

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

这儿你可以回复上面这条便签

captcha