last day (14 days later) » 

8:42 PM
5
A: Make List<Student> Distinctable with IEquatable<Student>

Matías FidemraizerSee what Enumerable.Distinct's docs says: The default equality comparer, Default, is used to compare values of the types that implement the IEquatable generic interface. To compare a custom data type, you need to implement this interface and provide your own GetHashCode and Equals metho...

 
Thank you for HashSet !!! that was very Helpful !
Could you please explain : why should we use " var x = students.Distinct(); " ??? It dose not work when I use " students.Distinct(); " ...
 
@Parsa Well not always you need a HashSet<T> but at certain point in your application flow you need to get unique elements within a collection so you call Distinct(). But if you've identified that you need to store unique elements, HashSet<T> is the winner!
@Parsa About Distinct(), did you assign the result of calling Distinct() to some variable?
 
No I did not assign in variable , but as you said , I should do . I was thinking why I shoud ?! , AND I am thinking which one should I choose ? HashSet VS Distinct :)))
 
@Parsa Others and me have already said that Distinct() doesn't modify the list but it returns a new enumerable containing the whole unique elements.
@Parsa The decision about using HashSet<T> or not is based on checking if you need to store unique elements or you need to be able to repeat items in the same collection.
hey
 
Hi
I shoud be thankfull of you
 
8:46 PM
why don't you read this post I composed some weeks ago? designpattern.ninja/news/2017/01/24/…
 
cuz of your very very helpfll explenation
 
it's about our topic and maybe you get te idea
no problem you're welcome ;)
the idea*
 
I will check it ;)
 
if you've any doubt about the post you can comment out it and I'll be glad to discuss your concerns :)
 
The article is great , this was what I wanted !!!
 

last day (14 days later) »