Click here to Skip to main content
15,912,897 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regex.Replace hangs !!! Pin
S. Senthil Kumar1-Nov-05 18:08
S. Senthil Kumar1-Nov-05 18:08 
GeneralRe: Regex.Replace hangs !!! Pin
whizzs2-Nov-05 10:29
whizzs2-Nov-05 10:29 
GeneralRe: Regex.Replace hangs !!! Pin
whizzs2-Nov-05 10:32
whizzs2-Nov-05 10:32 
QuestionHow to Retrieve Serial Ports and Parallel Ports in the current system by Using Visual C# Pin
sums081-Nov-05 10:26
sums081-Nov-05 10:26 
AnswerRe: How to Retrieve Serial Ports and Parallel Ports in the current system by Using Visual C# Pin
whizzs2-Nov-05 10:49
whizzs2-Nov-05 10:49 
GeneralRe: How to Retrieve Serial Ports and Parallel Ports in the current system by Using Visual C# Pin
sums083-Nov-05 5:35
sums083-Nov-05 5:35 
QuestionCustom Collections Pin
tsramkumar1-Nov-05 10:06
tsramkumar1-Nov-05 10:06 
AnswerRe: Custom Collections Pin
S. Senthil Kumar1-Nov-05 18:18
S. Senthil Kumar1-Nov-05 18:18 
tsramkumar wrote:
Indexof and Contains



IIRC, both of them use Equals[^] method to determine equality. The default implementation of Equals in System.Object checks if both references refer to the same object, you might want to override it to define equality in whatever way you want.

If you override Equals, it's recommended to override GetHashCode also, as per this[^] recommendation.

For example,
class Customer
{
   int id;
   public override bool Equals(object obj)
   {
      if (obj == null) return false;

      Customer b = obj as Customer;
      
       if ((object)b == null) return false;

      return this.id == b.id;
   }
   
   public override int GetHashCode()
   {
      return id; //assuming id is unique.
   }
}


Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
GeneralRe: Custom Collections Pin
tsramkumar2-Nov-05 3:06
tsramkumar2-Nov-05 3:06 
GeneralRe: Custom Collections Pin
S. Senthil Kumar2-Nov-05 4:37
S. Senthil Kumar2-Nov-05 4:37 
QuestionRigid body transformation parameters Pin
pxp1-Nov-05 9:54
pxp1-Nov-05 9:54 
QuestionAnother Dynamic Button Question Pin
TheMajorRager1-Nov-05 9:47
TheMajorRager1-Nov-05 9:47 
AnswerRe: Another Dynamic Button Question Pin
Wjousts1-Nov-05 10:45
Wjousts1-Nov-05 10:45 
QuestionLoop Through XML File Pin
Stephen McAllister1-Nov-05 9:34
Stephen McAllister1-Nov-05 9:34 
AnswerRe: Loop Through XML File Pin
MalikRizwan1-Nov-05 18:30
MalikRizwan1-Nov-05 18:30 
AnswerRe: Loop Through XML File Pin
S. Senthil Kumar1-Nov-05 18:43
S. Senthil Kumar1-Nov-05 18:43 
QuestionGet a column HeaderText Pin
zaboboa1-Nov-05 9:32
zaboboa1-Nov-05 9:32 
AnswerRe: Get a column HeaderText Pin
Wjousts1-Nov-05 10:51
Wjousts1-Nov-05 10:51 
Question[Message Deleted] Pin
Stephen McAllister1-Nov-05 9:31
Stephen McAllister1-Nov-05 9:31 
QuestionSort Array by Date properly Pin
Joshua Lunsford1-Nov-05 8:13
Joshua Lunsford1-Nov-05 8:13 
AnswerRe: Sort Array by Date properly Pin
Jon Sagara1-Nov-05 8:17
Jon Sagara1-Nov-05 8:17 
GeneralRe: Sort Array by Date properly Pin
Joshua Lunsford1-Nov-05 8:23
Joshua Lunsford1-Nov-05 8:23 
QuestionFile information Pin
KaptinKrunch1-Nov-05 6:57
KaptinKrunch1-Nov-05 6:57 
AnswerRe: File information Pin
Dan Neely1-Nov-05 7:09
Dan Neely1-Nov-05 7:09 
GeneralRe: File information Pin
KaptinKrunch1-Nov-05 7:30
KaptinKrunch1-Nov-05 7:30 

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.