How do you check if a collection contains duplicates?
Loading
How do you check if a collection contains duplicates?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal YelvePosted Sep 25, 2022, 5:11 AM
Rajanikant HawaldarPosted Sep 25, 2022, 4:44 AM
better don't allow to add duplicates, there is 'contains' utilize it or use collection which doesn't allow duplicates
Sachin SinghPosted Sep 24, 2022, 11:53 AM
for complex type use group by as Distinct won't work without IComparer implementation
Muhammad Imran AnsariPosted Sep 24, 2022, 11:35 AM
You can try the following code to check wheather a collection have duplicate value or not.