Hi , i got richtextBox control in form and a text file. I am getting text file to array and getting richtextbox1.text to other array than compare it and count words matching. But for example there are two "name" word in text file and three "and" word in richtextbox .. So if there is two same word in text file in richtextbox it cant be 3 or higher after 2 , it must be wrong word so it must not be counted. But HashSet is counting unique values only not looking for duplicates in text file. I wanna compare every word in text file with words in RichTextBox .. (sorr for my english.)
My Codes here ;
StreamReader sr = new StreamReader("c:\\test.txt",Encoding.Default);
string[] word = sr.ReadLine().ToLower().Split(' ');
sr.Close();
string[] word2 = richTextBox1.Text.ToLower().Split(' ');
var set1 = new HashSet<string>(word);
var set2 = new HashSet<string>(word2);
set1.IntersectWith(set2);
MessageBox.Show(set1.Count.ToString());