farshad  zamani

farshad zamani

  • NA
  • 6
  • 5.8k

C#. Dictionary(translator) implemention

Nov 26 2011 6:50 AM

I am building a dictionary. My database and everything is ready. Just I have an error. when I want to look for the meaning of a word which is given by the user. the application will look for the needed word anywhere. For example, when I want to look for the meaning of word "ONE" it will look anywhere in the database and once it find word "ONE" anywhere( like in the word " DONE") the meaning of that word will be retrieve which is wrong. Here is my code for looking for the meaning of the word. the Problem is with Contain syntax. but I don't know what should I do and how to code the program that it can LOOK FOR THE EXACT WORD.


public partial class Form1 : Form

    {

        DICTIONARYDBEntities db = null;


        public Form1()

        {

            InitializeComponent();

            db = new DICTIONARYDBEntities();

            //new TakeOutWordsAndTypes();

        }


        private void button1_Click(object sender, EventArgs e)

        {

            try

            {

                string text =textBox1.Text;



                DictionaryTable meaning =

                    (

                        from w in db.DictionaryTables

                        where w.Word_In_English.Contains(Text) // THE PROBLEM SHOULD BE HERE WITH THIS CONTAINS. I have tried == sign. but I will have another error for this and I cannot use == sign.

                        select w).FirstOrDefault();


                if (meaning != null)

                {

                    labeltype.Text = meaning.Word_Type;

                    labelmeaning.Text = meaning.Word_In_Malay;

                }

                else

                {

                    labeltype.Text = "";

                    labelmeaning.Text = "word not found";

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }



Answers (1)