Click here to Skip to main content
15,906,947 members
Home / Discussions / C#
   

C#

 
GeneralRe: remove duplicates from list collection Pin
Luc Pattyn15-Feb-11 2:36
sitebuilderLuc Pattyn15-Feb-11 2:36 
AnswerRe: remove duplicates from list collection Pin
musefan15-Feb-11 0:55
musefan15-Feb-11 0:55 
GeneralRe: remove duplicates from list collection Pin
arkiboys15-Feb-11 0:58
arkiboys15-Feb-11 0:58 
GeneralRe: remove duplicates from list collection Pin
musefan15-Feb-11 1:05
musefan15-Feb-11 1:05 
GeneralRe: remove duplicates from list collection Pin
arkiboys15-Feb-11 1:08
arkiboys15-Feb-11 1:08 
GeneralRe: remove duplicates from list collection Pin
musefan15-Feb-11 1:12
musefan15-Feb-11 1:12 
GeneralRe: remove duplicates from list collection Pin
arkiboys15-Feb-11 1:22
arkiboys15-Feb-11 1:22 
GeneralRe: remove duplicates from list collection [modified] Pin
musefan15-Feb-11 1:25
musefan15-Feb-11 1:25 
What are you talking about? Show me what code you have

As I have edited the compare does not work. But it will do if you override the Equals() function is your custom class. For example...

public override bool Equals(object obj)
{
   if (obj == null)
      return false;
   MyClass m = obj as MyClass;
   if (m == null)
      return false;

   return Name == m.Name && Value == m.Value;//you need to compare all relevant values here
}


EDIT: Microsoft recommend the GetHashCode function is also overridden along with the Equals function (see here[^]). Example...

public override int GetHashCode()
{
   return Name.GetHashCode() ^ Value;
}

Illogical thoughts make me ill
modified on Tuesday, February 15, 2011 7:37 AM

AnswerRe: remove duplicates from list collection Pin
Hum Dum15-Feb-11 0:56
Hum Dum15-Feb-11 0:56 
GeneralRe: remove duplicates from list collection Pin
arkiboys15-Feb-11 0:59
arkiboys15-Feb-11 0:59 
GeneralRe: remove duplicates from list collection Pin
Thomas Krojer15-Feb-11 1:04
Thomas Krojer15-Feb-11 1:04 
GeneralRe: remove duplicates from list collection Pin
arkiboys15-Feb-11 1:40
arkiboys15-Feb-11 1:40 
GeneralRe: remove duplicates from list collection Pin
musefan15-Feb-11 1:46
musefan15-Feb-11 1:46 
GeneralRe: remove duplicates from list collection Pin
RobCroll15-Feb-11 5:04
RobCroll15-Feb-11 5:04 
AnswerRe: remove duplicates from list collection [modified] Pin
wesch15-Feb-11 4:08
wesch15-Feb-11 4:08 
AnswerRe: remove duplicates from list collection Pin
Pete O'Hanlon15-Feb-11 5:27
mvePete O'Hanlon15-Feb-11 5:27 
QuestionHow can you track the mouse pointer if you leave the form...... Pin
glennPattonWork314-Feb-11 23:25
professionalglennPattonWork314-Feb-11 23:25 
AnswerRe: How can you track the mouse pointer if you leave the form...... Pin
reza assar14-Feb-11 23:53
reza assar14-Feb-11 23:53 
GeneralRe: How can you track the mouse pointer if you leave the form...... Pin
glennPattonWork315-Feb-11 1:29
professionalglennPattonWork315-Feb-11 1:29 
AnswerRe: How can you track the mouse pointer if you leave the form...... Pin
Pravin Patil, Mumbai15-Feb-11 0:27
Pravin Patil, Mumbai15-Feb-11 0:27 
GeneralRe: How can you track the mouse pointer if you leave the form...... Pin
glennPattonWork315-Feb-11 1:30
professionalglennPattonWork315-Feb-11 1:30 
AnswerRe: How can you track the mouse pointer if you leave the form...... Pin
Luc Pattyn15-Feb-11 2:20
sitebuilderLuc Pattyn15-Feb-11 2:20 
QuestionHow to access port80 Pin
Krishna Varadharajan14-Feb-11 19:53
Krishna Varadharajan14-Feb-11 19:53 
AnswerRe: How to access port80 Pin
Bernhard Hiller14-Feb-11 22:07
Bernhard Hiller14-Feb-11 22:07 
AnswerRe: How to access port80 Pin
Luc Pattyn15-Feb-11 2:21
sitebuilderLuc Pattyn15-Feb-11 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.