当前位置:Gxlcms > asp.net > asp.net中简体转繁体实现代码

asp.net中简体转繁体实现代码

时间:2021-07-01 10:21:17 帮助过:11人阅读

我还是直接贴例子在说明一下吧:
代码如下:
  1. <br>//Form1.cs <br>using System; <br>using System.Collections.Generic; <br>using System.ComponentModel; <br>using System.Data; <br>using System.Drawing; <br>using System.Text; <br>using System.Windows.Forms; <br>using EncodeMy; <br>namespace TestEnCode <br>{ <br>public partial class Form1 : Form <br>{ <br>public Form1() <br>{ <br>InitializeComponent(); <br>} <br>private void button1_Click(object sender, EventArgs e) <br>{ <br>EncodeRobert edControl = new EncodeRobert();//创建一个简繁转换对象 <br>txtResult.Text= edControl.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional,txtSource.Text);//进行简繁转换 <br>} <br>} <br>} <br> <br>注意:using EncodeMy;并非.net自带的类库,在Encode.dll中。要引用一下的。 <br>请到http://download.csdn.net/source/617532 <br>http://download.csdn.net/user/farawayplace613下载(不需要资源分的)该实例的代码。Encode.dll在Debug的文件夹内。 <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br>//Form1.Designer.cs <br>namespace TestEnCode <br>{ <br>partial class Form1 <br>{ <br>/// <summary> <br>/// 必需的设计器变量。 <br>/// </summary> <br>private System.ComponentModel.IContainer components = null; <br>/// <summary> <br>/// 清理所有正在使用的资源。 <br>/// </summary> <br>/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> <br>protected override void Dispose(bool disposing) <br>{ <br>if (disposing && (components != null)) <br>{ <br>components.Dispose(); <br>} <br>base.Dispose(disposing); <br>} <br>#region Windows 窗体设计器生成的代码 <br>/// <summary> <br>/// 设计器支持所需的方法 - 不要 <br>/// 使用代码编辑器修改此方法的内容。 <br>/// </summary> <br>private void InitializeComponent() <br>{ <br>this.txtSource = new System.Windows.Forms.TextBox(); <br>this.txtResult = new System.Windows.Forms.TextBox(); <br>this.button1 = new System.Windows.Forms.Button(); <br>this.label1 = new System.Windows.Forms.Label(); <br>this.label2 = new System.Windows.Forms.Label(); <br>this.SuspendLayout(); <br>// <br>// txtSource <br>// <br>this.txtSource.Location = new System.Drawing.Point(75, 26); <br>this.txtSource.Name = "txtSource"; <br>this.txtSource.Size = new System.Drawing.Size(100, 22); <br>this.txtSource.TabIndex = 0; <br>// <br>// txtResult <br>// <br>this.txtResult.Location = new System.Drawing.Point(75, 126); <br>this.txtResult.Name = "txtResult"; <br>this.txtResult.Size = new System.Drawing.Size(100, 22); <br>this.txtResult.TabIndex = 1; <br>// <br>// button1 <br>// <br>this.button1.Location = new System.Drawing.Point(75, 78); <br>this.button1.Name = "button1"; <br>this.button1.Size = new System.Drawing.Size(75, 23); <br>this.button1.TabIndex = 2; <br>this.button1.Text = "简繁转换"; <br>this.button1.UseVisualStyleBackColor = true; <br>this.button1.Click += new System.EventHandler(this.button1_Click); <br>// <br>// label1 <br>// <br>this.label1.AutoSize = true; <br>this.label1.Location = new System.Drawing.Point(23, 29); <br>this.label1.Name = "label1"; <br>this.label1.Size = new System.Drawing.Size(41, 12); <br>this.label1.TabIndex = 3; <br>this.label1.Text = "转换源"; <br>// <br>// label2 <br>// <br>this.label2.AutoSize = true; <br>this.label2.Location = new System.Drawing.Point(12, 136); <br>this.label2.Name = "label2"; <br>this.label2.Size = new System.Drawing.Size(53, 12); <br>this.label2.TabIndex = 4; <br>this.label2.Text = "转换结果"; <br>// <br>// Form1 <br>// <br>this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); <br>this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; <br>this.ClientSize = new System.Drawing.Size(320, 277); <br>this.Controls.Add(this.label2); <br>this.Controls.Add(this.label1); <br>this.Controls.Add(this.button1); <br>this.Controls.Add(this.txtResult); <br>this.Controls.Add(this.txtSource); <br>this.Name = "Form1"; <br>this.Text = "简繁体转换测试"; <br>this.ResumeLayout(false); <br>this.PerformLayout(); <br>} <br>#endregion <br>private System.Windows.Forms.TextBox txtSource; <br>private System.Windows.Forms.TextBox txtResult; <br>private System.Windows.Forms.Button button1; <br>private System.Windows.Forms.Label label1; <br>private System.Windows.Forms.Label label2; <br>} <br>} <br> <br>注意了,上面下载地下载的是VS2008创建的项目. <br>可能需要你把代码拷贝到你自己的环境中。下载中重要的是Encode.dll。 <br>哈哈,简单吧,就两句就搞定了简繁体的转换。 <br>作者:程呈<br>原文来自:http://blog.csdn.net/farawayplace613/archive/2008/09/10/2910527.aspx</li><li> </li><li> </li></ol></pre>

人气教程排行