There are a number of ways to do this, and the easiest is to use Linq.
But...since you seem to be a beginner you may not have reached that yet, and it's pretty simple to find duplicates if you think about it for a moment.
The List<T> collection has a
Sort method[
^], and if you order your values then duplicates will be next to each other:
List<string> objList = new List<string>() {"A", "C", "B", "Z", "B"};
obList.Sort();
Once they are sorted, duplicates are next to each other, so it's a simple matter to find duplicates:
string last = "";
foreach (object eachItem in objList )
{
if (eachItem == last)
{
Console.WriteLine("Duplicate: {0}", eachItem);
}
last == eachItem;
}