var found = mycollection.FirstOrDefault(x=>x.name == text); if (found == null) { mycollection.Add(text); } else { MessageBox.Show("Duplicate names are not allowed."); }
System.Collections.Generic.HashSet<T>
string text = "Some Text"; var mySet = new HashSet<string>(); if (mySet.Contains(text)) Console.WriteLine("Duplicate!"); else mySet.Add(text);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)