tagged [equality]
Tuple vs string as a Dictionary key in C#
Tuple vs string as a Dictionary key in C# I have a cache that I implement using a ConcurrentDictionary, The data that I need to keep depends on 5 parameters. So the Method to get it from the cache is:...
- Modified
- 2 Feb at 12:22
Which equals operator (== vs ===) should be used in JavaScript comparisons?
Which equals operator (== vs ===) should be used in JavaScript comparisons? I'm using [JSLint](http://en.wikipedia.org/wiki/JSLint) to go through JavaScript, and it's returning many suggestions to rep...
- Modified
- 22 Mar at 16:13
GetHashCode() for OrdinalIgnoreCase-dependent string classes
GetHashCode() for OrdinalIgnoreCase-dependent string classes I'd like to implement a notion of distint addresses, so I overrode Equals() to test for case-insensitive equality in all of the fields (as ...
String comparison : operator==() vs. Equals()
String comparison : operator==() vs. Equals() > [C#: Are string.Equals() and == operator really same?](https://stackoverflow.com/questions/3678792/c-are-string-equals-and-operator-really-same) For s...
How to test two dateTimes for being the same date?
How to test two dateTimes for being the same date? > [How to compare Dates in C#](https://stackoverflow.com/questions/683037/how-to-compare-dates-in-c-sharp) This code of mine: ...fails even when th...
Comparing boxed value types
Comparing boxed value types Today I stumbled upon an interesting bug I wrote. I have a set of properties which can be set through a general setter. These properties can be value types or reference typ...
What's the difference between IEquatable and just overriding Object.Equals()?
What's the difference between IEquatable and just overriding Object.Equals()? I want my `Food` class to be able to test whenever it is equal to another instance of `Food`. I will later use it against ...
- Modified
- 1 Aug at 04:32
Comparing two List<string> for equality
Comparing two List for equality Other than stepping through the elements one by one, how do I compare two lists of strings for equality (in .NET 3.0): This fails: ``` // Expected result. List expect...
- Modified
- 27 Nov at 22:43
When would == be overridden in a different way to .equals?
When would == be overridden in a different way to .equals? I understand the difference between == and .equals. There are plenty of other questions on here that explain the difference in detail e.g. th...
Correct way to override Equals() and GetHashCode()
Correct way to override Equals() and GetHashCode() I have never really done this before so i was hoping that someone could show me the correct what of implementing a override of Except() and GetHashCo...
- Modified
- 28 Feb at 14:37
Is there a difference between "==" and "is"?
Is there a difference between "==" and "is"? My [Google-fu](https://english.stackexchange.com/questions/19967/what-does-google-fu-mean) has failed me. In Python, are the following two tests for equali...
Compare object instances for equality by their attributes
Compare object instances for equality by their attributes I have a class `MyClass`, which contains two member variables `foo` and `bar`: I have two instances of this class, each of which has identical...
Difference between == and === in JavaScript
Difference between == and === in JavaScript What is the difference between `==` and `===` in JavaScript? I have also seen `!=` and `!==` operators. Are there more such operators?
- Modified
- 9 Nov at 14:31
equals vs Arrays.equals in Java
equals vs Arrays.equals in Java When comparing arrays in Java, are there any differences between the following 2 statements? And if so, what are they?
Python3 Determine if two dictionaries are equal
Python3 Determine if two dictionaries are equal This seems trivial, but I cannot find a built-in or simple way to determine if two dictionaries are equal. What I want is: ``` a = {'foo': 1, 'bar': 2} ...
- Modified
- 17 Mar at 12:20
What is "Best Practice" For Comparing Two Instances of a Reference Type?
What is "Best Practice" For Comparing Two Instances of a Reference Type? I came across this recently, up until now I have been happily overriding the equality operator () and/or method in order to see...
- Modified
- 20 Jun at 09:12
Custom Equality check for C# 9 records
Custom Equality check for C# 9 records From what I understand, records are actually classes that implement their own equality check in a way that your object is value-driven and not reference driven. ...
Testing for equality between dictionaries in C#
Testing for equality between dictionaries in C# Assuming dictionary keys and values have their equals and hash methods implemented correctly, what is the most succinct and efficient way to test for eq...
- Modified
- 16 Apr at 03:0