Dictionary<string,int> dict= new Dictionary<string,int>();
string str = "the elephant jumps on the ball";
string [] a = str.Split(new char []{' '});
foreach( string s in a)
{
if (dict.ContainsKey(s) )
dict[s]++;
else
dict[s]=1;
}
foreach(string k in dict.Keys)
{
if (dict[k] == 2) Console.WriteLine(k);
}
:)