I have the following string with comma between in my windows form C#
string computernames = "Computer1,Computer2,Computer3,Computer2,Computer1";
as you see there are duplicates of Computer1 and Computer2.
How can I check those duplicates?
I tried the following but it doesn't find any duplicate.
How should I write my code?
string[] arraylist = computernames.Split(',');
var groups = arraylist.GroupBy(v => v);
foreach (var item in groups)
{
if(item.Count() > 1)
{
MessageBox.Show("There is dubblication of computer name");
return;
}
}