简体繁体字转换。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace 简繁字体转换
{
public partial class Form1 : Form
{
private Dictionary dict = new Dictionary();
public Form1()
{
InitializeComponent();
}

private void btnConvert_Click(object sender, EventArgs e)
{

string input = txtCHS.Text.Trim(); //获取用户输入的简体中文

StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.Length; i++)
{

if (dict.ContainsKey(input[i])) //判断字典中是否包含这个键
{
sb.Append(dict[input[i]]);
}
else
{
sb.Append(input[i]); //如果dict中不包含,原样输出
}

}

txtCHT.Text = sb.ToString();
}

private void Form1_Load(object sender, EventArgs e)
{
string[] lines = File.ReadAllLines("ST.txt");
for (int i = 0; i < lines.Length; i++)
{
dict.Add(lines[i][0], lines[i][2]);
}
}
}
}

你可能感兴趣的:(简体繁体字转换。)