博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c# 汉字换英文,英文转汉字
阅读量:4647 次
发布时间:2019-06-09

本文共 1556 字,大约阅读时间需要 5 分钟。

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;namespace _01英汉翻译{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            if (dic.ContainsKey(txtEnglish.Text.Trim()))            {                txtChinese.Text = dic[txtEnglish.Text.Trim()];            }        }        Dictionary
dic = new Dictionary
(); private void Form1_Load(object sender, EventArgs e) { string[] lines = File.ReadAllLines("英汉词典.txt", Encoding.Default); for (int i = 0; i < lines.Length; i++) { string[] temp = lines[i].Split(new char[] { ' ','\t' }, StringSplitOptions.RemoveEmptyEntries); string chinese = string.Empty; //把除了第一项的英文单词 后面所有的中文解释的累加给chinese //temp[i] abandon v.抛弃 放弃 for (int j = 1 ; j < temp.Length; j++) { chinese += temp[j]; } if (!dic.ContainsKey(temp[0])) { dic.Add(temp[0], chinese); } else { dic[temp[0]] += chinese; } } } }}

 

转载于:https://www.cnblogs.com/suanshun/p/7001639.html

你可能感兴趣的文章
网络表示学习总结
查看>>
完成评论功能
查看>>
far和near
查看>>
Python爬虫实战四之抓取淘宝MM照片
查看>>
2015 Multi-University Training Contest 1
查看>>
C#判断一个字符串是否是数字或者含有某个数字
查看>>
SVN使用指南
查看>>
【转载】掌 握 3 C ‧ 迎 接 亮 丽 职 涯
查看>>
爬取网站附件
查看>>
java基础图形界面和IO系统
查看>>
javascript学习笔记
查看>>
hdu 3996
查看>>
python第三十九课——面向对象(二)之初始化属性
查看>>
python学习笔记之函数装饰器
查看>>
FEM计算2D瞬态热传导方程
查看>>
四年时光,匆匆而过
查看>>
【php】【psr】psr1 基础编码规范
查看>>
WAF SSI
查看>>
LDAP & it's implementation
查看>>
Apache HttpComponents中的cookie匹配策略
查看>>