Hello,
The following uses C#9 new expressions e.g. List<string> listValues = new ()
rather than List<string> listValues = new List<string>()
The following uses a language extension.
public static class Extensions
{
public static bool HasDuplications(this List<string> sender) =>
sender.GroupBy(value => value).Any(@group => @group.Count() > 1);
public static string ToYesNoString(this bool value) => value ? "Yes" : "No";
}
First we get yes then no.
List<string> listValues = new ()
{
"E-10-XN-PP",
"E - 10 - XN - MM",
"E - 10 - XN - MM"
};
Debug.WriteLine(listValues.HasDuplications().ToYesNoString());
listValues.RemoveAt(1);
Debug.WriteLine(listValues.HasDuplications().ToYesNoString());