Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
64 views

This is puzzling me greatly. This tiny bit of test code is failing with a KeyNotFoundException. foreach (var key in this.Keys) { List<ValidationDirective> test = this[key]; } It seems ...
Russ S.'s user avatar
1 vote
2 answers
114 views

I want to use string as a key type in a Dictionary. Like Dictionary<string, string>. As I understand, if I want to Add a new object, it first calculate a hashcode of the key. So the complexity ...
Nikita Aznauryan's user avatar
3 votes
2 answers
744 views

I have a HashSet<T> and I want to get the hashcode of the HashSet<T> based on the items it contains. I am trying to identify a HashSet<T> based on it's values. I know I can use set ...
karthik suryadevara's user avatar
0 votes
1 answer
132 views

I have a class Bar that looks like this: public class Bar : IEquatable<Bar> { public string Stringbar1{ get; set; } public string Stringbar2{ get; set; } public string Stringbar3{ ...
Mohamad Hammash's user avatar
42 votes
2 answers
5k views

Consider the following code: Console.WriteLine("Hello, World!".GetHashCode()); First run: 139068974 Second run: -263623806 Now consider the same thing written in Kotlin: println("...
Matthew Layton's user avatar
2 votes
1 answer
158 views

function getHash( string ) { let h = 7, letters = "acdefhlmnoprstuw"; for( var i = 0; i < string.length; i++ ) { h = ( h * 37 + letters.indexOf( string[ i ] ) ); } ...
Vkx's user avatar
  • 49
0 votes
0 answers
42 views

When create a linkedlist in hash class search method, my iterator does not work with it. What can i use instead of iterator? How can i fix it. public static void search(String keyword){ String ...
Anon's user avatar
  • 41
0 votes
0 answers
33 views

Let's say I have a POCO that represents a database row. I have access to the ID of that row. Is it safe to implement GetHashCode and Equals by leveraging that unique ID ? public class Project { ...
Arthur Attout's user avatar
2 votes
2 answers
118 views

I have a playing card class with the GetHashCode method implemented as follows: public override int GetHashCode() { return (int)rank * 4 + (int)suit; } I now want to design a GetHashCode method ...
Steve W's user avatar
  • 1,148
1 vote
1 answer
632 views

class A { public int Age{get;set;} public override GetHashCode() { return Age.GetHashCode(); } } class B : A { public int Name{get;set;} public override GetHashCode() ...
m5rP4Z4q4's user avatar
2 votes
2 answers
337 views

Reading the Castle.Core documentation, in this link, they recommend that always overriding the Equals and GetHashCode methods of the classes that implement IProxyGenerationHook. I have a class called ...
Marlonchosky's user avatar
1 vote
0 answers
159 views

I am using a JWT token's hash as part of a cache key, since I want to provide different values when a different token is used. The hash code is calculated in service written in .NET Framework, and is ...
Omer's user avatar
  • 83
0 votes
1 answer
288 views

I have an object like below; var json = @"{ 'TableNumber': '3', 'TableId': '81872d39-9480-4d2d-abfc-b8e4f33a43b6', 'tableMenuItems': [ { 'Id': '4664a2d3-c0af-443d-8af5-...
Cemal's user avatar
  • 153
0 votes
1 answer
164 views

I have a function which looks like this: public int getHashcode(int shardCount){ String personid = "<some long string value>"; String servicedate = "2019-12-22T01:31:30.000Z"; ...
varsha Das's user avatar
-1 votes
1 answer
91 views

I made a class that include List<T>.(T is a struct I made.) And I want to override Equals() and GetHashCode(). So I need to make HashCode from List<T>. How can I make good HashCode from ...
kdm1jkm's user avatar
1 vote
0 answers
31 views

My WPF binding is not working because my viewmodel has overwritten Equals and GetHashCode. If i comment it out (region Object-Stuff), everything works fine. Further info about my reasons: All my ...
Dosihris's user avatar
  • 145
1 vote
1 answer
511 views

Maybe I don’t understand something. No, I definitely don’t understand something. There is a custom class with two int type properties. Overriding the GetHashCode method, I want to use both of these ...
Konstantin's user avatar
0 votes
2 answers
228 views

I'm using a Line class in VisualStudio C# project from a third party (no access to the source) My code is generating hundreds/thousands of line objects containing duplicates and I need to store them ...
tlatev's user avatar
  • 25
0 votes
1 answer
2k views

Moving from Java to C# developer. In Java, I used a lot of Objects.hash(array) and Objects.hashCode(object) to build hash code of an object in hashCode function. I can't find any equivalent for those ...
LHA's user avatar
  • 9,715
1 vote
1 answer
484 views

In the implementation of GetHashCode below, when Collection is null or empty will both result in a hash code of 0. A colleague suggested return a random hard coded number like 19 to differentiate ...
Muhammad Rehan Saeed's user avatar
5 votes
2 answers
2k views

I recently discovered that Visual Studio 2017 can auto-generate overrides for Equals and GetHashCode, but I was wondering why the GetHashCode implementation is not in an unchecked block? I made a ...
TJR's user avatar
  • 3,822
1 vote
3 answers
873 views

I'm trying to create a hashcode method. I have code like below : private static object GetValue<T>(object item, string propertyName) { ParameterExpression arg = Expression....
Sinan AKYAZICI's user avatar
0 votes
0 answers
66 views

Seems like How does HashSet Compare elements for equality, but different, because that question focusses on the IEqualityComparer used by the HashSet. I want to write an Equality Comparer that ...
Harald Coppoolse's user avatar
1 vote
2 answers
202 views

My current project uses Dapper to build a class based on rows from a database. I've cut down my class to focus on the equality components of my question so please let me know if any additional code ...
Bluecakes's user avatar
  • 2,179
2 votes
0 answers
59 views

I was scratching my head over an unexpected failing comparison between two instances of a custom struct. I hope someone can either point me to reference source or documentation, or confirm whether ...
Oly's user avatar
  • 2,519

1
2 3 4 5
7