Firstly, you talk about using an
ArrayList
, this is no longer recommended. You should probably use a
List<string>
(
MSDN page[
^]).
Accepting that you do this, something like the following should do the trick:
List<string> uniqueWords = new List<string>();
foreach (string word in arrayWordsOnly)
{
key = word.Trim(spChar).ToLower();
if (!uniqueWords.Contains(key))
{
uniqueWords.Add(key);
}
}
If you are determined to use
ArrayList
then simply replace each occurrence of
List<string>
with
ArrayList