close
C# 視窗程式範例--視窗版小字典

專案下載:WinDictionary.zip

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;
namespace WindowsFormsApplication1
{
    public partial class FormDictionary : Form
    {
        Dictionary<String, String> dict = new Dictionary<string, string>();
        public FormDictionary()
        {
            InitializeComponent();
        }
        private void buttonQuery_Click(object sender, EventArgs e)
        {
            try
            {
                String eword = comboBoxQuery.Text;
                String cword = dict[eword];
                richTextBox.Text = cword;
            }
            catch
            {
                MessageBox.Show("輸入錯誤,查不到!");
            }
        }
        private void FormDictionary_Load(object sender, EventArgs e)
        {
            String[] eWords = new String[] { "dog", "cat", "eat", "chase", "run", "a",    "the" };
            String[] cWords = new String[] { "狗",  "貓",  "吃",  "追",     "跑",  "一隻", "這隻" };
            for (int i = 0; i < eWords.Length; i++)
            {
                dict.Add(eWords[i], cWords[i]);
            }
        }
    } 
	

}

文章來源:陳鍾誠 (2012年10月23日),(網頁標題) 視窗版小字典,(網站標題) 免費電子書:C# 程式設計,2012年10月23日,取自 http://cs0.wikidot.com/windictionary ,網頁修改第 4 版。

arrow
arrow
    創作者介紹
    創作者 Johnson峰 的頭像
    Johnson峰

    Johnson峰的部落格

    Johnson峰 發表在 痞客邦 留言(0) 人氣()