you can use LINQ GroupBy
to check the distinct:
bool flag = s.row.ItemArray.Where(x => x != null)
.Where(x => (x is string) && !string.IsNullOrEmpty((string) x))
.GroupBy(x => x).Any(g => g.Count() > 1);
How it works:
To simplify, assume your item array has: [1, 1, 3, 3]. GroupBy(x => x)
will group your array in two group:
[ [1, 1], [3, 3] ]
To know whether it is distinct or not, you just check whether any group has Count
> 1, if yes, it is not distinct. Example in here is not distinct