Finding the difference in 2 strings : <p>I have 2 texboxes in a PowerPoint. One original and one edited. I get these to string and break them each up into an array. I then compare them for any differences. For example my original Text box has "This New" and my edited has "Thisss Blaa" the output is then "This Thisss New Blaa". However when my original TextBox has the same word twice e.g. "This This" my output is "This Thiss Blaa" where it should be "This Thiss This Blaa". This only happens when I have 2 of the same words in a string. Has anyone got any ideas how to fix this?</p>

<p>My code is as follows</p>

<pre><code>            var q = from original in originalList
                    join editedTmp in editList on original.Id equals editedTmp.Id into g
                    from edited in g.DefaultIfEmpty()
                    select new
                    {
                        original,
                        edited
                    };
            foreach (var item in q)
            { 



            char delimiter = Convert.ToChar(" ");
            var originalString = item.original.TextFrame.TextRange.Text;
            var editString = item.edited.TextFrame.TextRange.Text;

            var firstStringList = originalString.Split(delimiter).ToList();

            var secondStringList = editString.Split(delimiter).ToList();


            foreach (var word in firstStringList)
            {
                if (secondStringList.IndexOf(word) == -1)
                {




                    var indexOfWord = firstStringList.IndexOf(word); //gets the position of the edited word eg. 3.
                                                                     // using indexOfWord+indexOfWord as I need do this if more than one word is added.
                    secondStringList.Insert(indexOfWord + indexOfWord, word);

                    // Insert the word that was not found at position 3 inside secondStringList

                    one.Add(word);


                    }
            }
</code></pre>
