Questions tagged [iequatable]

Interface, which defines a generalized method that a value type or class implements to create a type-specific method for determining equality of instances.

165 questions
0
votes
1 answer

Implementing GetHashCode on a value class

I have a class Money and I want to know what the best way of implementing GetHashCode on this value class would be give that $1 != €1. Having a weighted value against the currency * value is not going to work. public class Money :…
user1054637
  • 695
  • 11
  • 28
0
votes
1 answer

Distinct is not working with IEquatable

I have a class Bar that looks like this: public class Bar : IEquatable { public string Stringbar1{ get; set; } public string Stringbar2{ get; set; } public string Stringbar3{ get; set; } public string Stringbar4{ get; set; } …
Mohamad Hammash
  • 237
  • 1
  • 8
0
votes
1 answer

I am having a CA1067 violation on IEquatable(Of T) and can't solve it

I have been trying for hours and a lot recode but can get rid of the CA1067 violation. Using: Visual Studio 2022, .Net v6.0.13, VB.NET I will appreciate any help to solve the issue and insights in what I am doing wrong. So the case is the…
0
votes
2 answers

How should I implement equality checking for classes that have objects of other classes as member?

I have a Student class that has an object of class Name. At this point, the equality check of the Student class returns false, and I don't know why. public class Student : IEquatable { public Name Name { get; } public Student(Name…
isakgo_
  • 750
  • 4
  • 15
0
votes
1 answer

Possible null reference in IEquatable implementation

I'm trying to find out how to remove that possible null reference in the IEquatable implementation below. return other != null && _guid == other._guid; Possible null reference argument for parameter 'left' in 'bool SubscriptionToken.operator…
nop
  • 4,711
  • 6
  • 32
  • 93
0
votes
1 answer

How to emit empty state more than one time when I am using equatable

I am trying to emit a state more than one time because I am validating a form no need to add any thing on the constructor and make copyWith func etc.. so could you help me with other solutions? class PersonUnValid extends PersonState { const…
Mo_
  • 45
  • 9
0
votes
0 answers

How to implement priority queue using Custom interfaces as attached in both the images?

using System; using System.Collections.Generic; using System.Linq;   namespace MyQueue {     public class PriorityQueue where T : IEquatable     {         private IDictionary> elements;                  public PriorityQueue()    …
0
votes
2 answers

OnDrawGizmos not drawing all Grid positions in generated Grid

I have a Grid I am generating to perform path finding. When storing all the walkable Nodes I perform a check if the Obstacles HashSet has an obstacle placed there. I am passing a Node to the IsCellOccupied(Node node) function but I think .Contains…
Krellex
  • 613
  • 2
  • 7
  • 20
0
votes
1 answer

How to Implement IEquatable in a class that

I need to have instances of a DispenseFile class that inherits from DispenseEntity that implements IDispenseEntity use a custom equality for purposes of comparing elements in List. My interface is: public interface IDispenseEntity :…
Eric Snyder
  • 1,816
  • 3
  • 22
  • 46
0
votes
2 answers

how to compare values of two reference type nested and dynamic objects

I have two objects with the same type and values how can I compare them by value? exp: class Person { public string Name { get; set; } public DateTime BirthDate { get; set; } public Address Address { get; set; } …
MM Hamzeh
  • 25
  • 7
0
votes
2 answers

Comparing two collections of same object in C# and Finding New, Changed or Deleted Records

I have got two collections of same object public class MyClass { public int Id {get;set;} public string Name {get;set;} public int Age{get;set;} public string SSN{get;set;} } I have got two Collections (colA and colB) based on MyClass…
0
votes
1 answer

IEquatable Documentation is confusing

Hi I am trying to add in IEquatable to my program and I have no clue if I need to add a unique id basicly and a hashcode? They are using the shd number as a unique id in the IEquatable but they give the value to it in the constructor and I asked on…
user13319447
0
votes
0 answers

IEquatable documentation?

I have looked through IEquatables documentation from microsoft and have some stuff i do not understand with the implementation of it? well not something what i do not understand is this part public Person(string lastName, string ssn) { …
user13319447
0
votes
1 answer

How to enforce adding new public properties to the Equals method for IEquatable classes

I have classes that contain other child classes, so I have implemented IEquatable to perform a custom Equals method recursively down the chain. That is working fine, but I am thinking if other developers need to add new public properties to these…
0
votes
1 answer

How to Implement IEquatable with Different Equality Checks

I have a MyCustomSet class with IEquatable implemented as shown below. This works fantastic when I want to check equality for all three sets (SetA*, SetB*, and SetC*). But requirements dictate that I also need the ability to check equality for only…
Ari Pub
  • 11
  • 4