Import English-Chinese text, cut with string, generic collection storage of English-Chinese dictionaries

Source: Internet
Author: User

 usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;namespaceImport English-Chinese text, cut with string, generic collection stored in English-Chinese dictionary { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Dictionary<string,string> dic =Newdictionary<string,string>(); Private voidForm1_Load (Objectsender, EventArgs e) {            //when the form loads//Create a dictionary//Read File            string[] lines= File.ReadAllLines ("1.txt", Encoding.default); //traverse each row             for(inti =0; I < lines. Length; i++)            {               string[]words= Lines[i]. Split (New Char[]{' '}, Stringsplitoptions.removeemptyentries); //Merge the Chinese meaning               stringChinese ="";  for(intj =1; J < words. Length; J + +) {Chinese+ = Words[j];//Merging Chinese meanings               }               if(!dic. ContainsKey (words[0]))//Judging if there is a word in the dictionary,{dic. ADD (words[0],chinese);//If you don't have the word, add the word and meaning to the dictionary.               }               Else               {                   //the word already exists in the dictionary,dic[words[0]] +=Chinese; }                         }        }        Private voidBtnok_click (Objectsender, EventArgs e) {            //remove an English word from the first text box//determine if the word exists in the dictionary, and if it exists, show the Chinese meaning            if(DIC. ContainsKey (TxtEnglish.Text.ToLower ())) {Txtchinese.text=Dic[txtenglish.text.tolower ()]; }            Else{Txtchinese.text="the word is not included in the dictionary"; }                        //If it does not exist, the word is not included in the dictionary        }    }}

Import English-Chinese text, cut with string, generic collection storage of English-Chinese dictionaries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.