iequatable
Find an item inside a List<T> by providing a sample object instance
Why is there a List<T>.Contains(T) method but no List<T>.Find开发者_运维百科(T) method? Only the Finds that support predicates are supported. If we have an existing instance of T populated[详细]
2023-03-28 09:05 分类:问答Custom object using Except failing to use IEqualityComparer<T>
here is the object code: public class DlpItem : IEqualityComparer<DlpItem> { public string Text { get; set; }[详细]
2023-02-19 15:28 分类:问答What should GetHashCode return when object's identifier is null?
Which of the following is correct/better, considering that identity property could be null. public override int GetHashCode()[详细]
2023-02-12 08:11 分类:问答collections.Contains(T) method
I am using a System.Collections.Generic, which contains instances of a class I wrote. I have read that the collections .Contains method uses object.Equals(), or an implementation of the Equals() meth[详细]
2023-02-07 03:37 分类:问答Linq Distinct with a single comparison class (and interface)
I have several classes in my application, all of which have a Name property that I want to use as m开发者_如何学Pythony basis for comparison (Distinct(), etc.).Since I am always going to be comparing[详细]
2023-02-01 15:57 分类:问答What's the difference between obj1.Equals(obj2) and static Object.Equals(obj1, obj2) in c#?
from the documentation by Microsoft, both Equals-methods are essentially the same. But I just stumbled across something开发者_高级运维 very strange.[详细]
2023-01-15 18:45 分类:问答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 a List, and I want to use its List.Contains() method. Should I implement IEquatabl[详细]
2022-12-29 02:07 分类:问答How to implement IEquatable<T> when mutable fields are part of the equality - Problem with GetHashCode
I am using Entity Framework in my application. I implemented with the partial class of an entity the IEquatable<T> interface:[详细]
2022-12-26 20:15 分类:问答When To Use IEquatable<T> And Why
What does IEquatable<T> buy you, exactly? The only re开发者_StackOverflow中文版ason I can see it being useful is when creating a generic type and forcing users to implement and write a good equa[详细]
2022-12-23 17:13 分类:问答GetHashCode on null fields?
How do I deal with null fields in GetHashCode function? Module Module1 Sub Main() Dim c As New Contact Dim hash = c.GetHashCode[详细]
2022-12-23 11:30 分类:问答