Tagged Questions
0
votes
2answers
55 views
Compare Objects' properties using hashcode
I need to know the ways to compare many objects using hashcode. So here is one of the class.
public class Test: IEquatable<Test>
{
public Test()
{
}
public string ID { get; ...
382
votes
9answers
27k views
What is the best algorithm for an overridden System.Object.GetHashCode?
In .NET System.Object.GetHashCode method is use in a lot of places throughout the .NET base class libraries. Especially when finding items in a collection fast or to determine equality. Is there a ...
0
votes
2answers
43 views
GetHashCode conflicts
I know it's not very smart to use HashCode as a unique identifier,
but let's say I have two variables on the same HashCode is the only way I can get them,
how can I tell the difference?
0
votes
1answer
51 views
Is it possible a hash code of mobile number is converted in to real number i want to know mobile number from my mobile number hash code
Is it possible a hash code of mobile number is converted in to real number i want to know mobile number from given mobile number hash code?Just as a testing purpose
42
votes
9answers
22k views
.NET unique object identifier
Is there any way of getting an unique identifier of an instance?
GetHashCode() is the same for the two references pointing to the same instance. However, two different instances can (quite easily) ...
2
votes
2answers
1k views
Good GetHashCode() override for List of Foo objects
EnumerableObject : IEnumerable<Foo>
wraps a List<Foo>
If EnumerableObject a.SequenceEquals( EnumerableObject b), then they are equal.
Therefore, a GetHashCode must be implemented. The ...
12
votes
5answers
872 views
Why might a System.String object not cache its hash code?
A glance at the source code for string.GetHashCode using Reflector reveals the following (for mscorlib.dll version 4.0):
public override unsafe int GetHashCode()
{
fixed (char* str = ((char*) ...
11
votes
8answers
2k views
GetHashCode Extension Method
After reading all the questions and answers on StackOverflow concerning overriding GetHashCode() I wrote the following extension method for easy and convenient overriding of GetHashCode():
public ...
0
votes
2answers
1k views
Comparing two custom Objects (using IEqualityComparer)
Firstly, I will say what I want to compare the following: My Custom Object (Item) has a List of strings taxids. I want to look if all the strings in one List occur in another list of strings (will be ...
10
votes
7answers
2k views
Why does C# not implement GetHashCode for Collections?
I am porting something from Java to C#. In Java the hashcode of a ArrayList depends on the items in it. In C# I always get the same hashcode from a List...
Why is this?
For some of my objects the ...
9
votes
5answers
2k views
How do I create a HashCode in .net (c#) for a string that is safe to store in a database?
To quote from Guidelines and rules for GetHashCode by Eric Lippert:
Rule: Consumers of GetHashCode cannot rely upon it being stable over time or across appdomains
Suppose you have a ...
0
votes
1answer
1k views
e.keyChar does not work for Ctrl
This code shows hashcodes of pressed button, but when i press on Control button i does not do anything. Can help me someone?
private void treeView1_KeyPress(object sender, KeyPressEventArgs e)
{
...
0
votes
2answers
393 views
Generating Hash Code for Object
I have a custom object (DataPointCollection) with two Integer properties and a Guid property. I want that object to generate a HashCode so that no two objects with the same values in those properties ...
2
votes
1answer
270 views
wpf overriding getHashCode and Eqaul in ContentControl
Hi
I have a class which derives from ContentControl and I'm not able to override GetHashCode and Equal method. I get an error
Error 5 cannot override inherited member ...
7
votes
3answers
9k views
Creating the GetHashCode method in C#
What is the best way to create your own GetHashCode method for a class in C#? Suppose I have a simple class (which overrides the Equals method), as follows:
class Test
{
public string[] ...