Questions tagged «iequatable»

4
IEquatable和仅重写Object.Equals()有什么区别?
我希望我的Food课程能够在等于的另一个实例时进行测试Food。稍后将针对列表使用它,并且我想使用其List.Contains()方法。我应该实施IEquatable<Food>还是仅重写Object.Equals()?从MSDN: 此方法通过使用默认的相等比较器确定相等,该比较器由对象的IEquatable.Equals方法实现,用于T(列表中值的类型)。 所以我的下一个问题是:.NET框架的哪些函数/类使用了Object.Equals()?我应该首先使用它吗?
183 c#  .net  equals  equality  iequatable 


9
与LINQ to Objects不兼容的区别
class Program { static void Main(string[] args) { List<Book> books = new List<Book> { new Book { Name="C# in Depth", Authors = new List<Author> { new Author { FirstName = "Jon", LastName="Skeet" }, new Author { FirstName = "Jon", LastName="Skeet" }, } }, new Book { Name="LINQ in Action", Authors …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.