How to find whether the List<string>
has duplicate values or not ?
I tried with below code. Is there any best way to achieve ?
var lstNames = new List<string> { "A", "B", "A" };
if (lstNames.Distinct().Count() != lstNames.Count())
{
Console.WriteLine("List contains duplicate values.");
}