score:2

Accepted answer
 var setOne = new HashSet<string>(textBoxWords.Text
                               .Split(new char [] { '\r', '\n' })
                               .Select(s1 => s1.Trim())
                               .Where(s2 => !String.IsNullOrEmpty(s2)));

It's not exactly the same as what you have since the result is a HashSet, but based on your scenario it looks like that may be the better data structure for what you are trying to accomplish.

score:1

Your examples are already fairly simple. One alternative would be:

(from s in textBoxWords.Split(new char[] { '\r', '\n' })
where !string.IsNullOrEmpty(s)
select s.Trim()).Distinct();

Related Articles