Questions tagged «iequalitycomparer»


3
.NET中IEqualityComparer <T>中GetHashCode的作用是什么?
我试图了解IEqualityComparer接口的GetHashCode方法的作用。 以下示例来自MSDN: using System; using System.Collections.Generic; class Example { static void Main() { try { BoxEqualityComparer boxEqC = new BoxEqualityComparer(); Dictionary&lt;Box, String&gt; boxes = new Dictionary&lt;Box, string&gt;(boxEqC); Box redBox = new Box(4, 3, 4); Box blueBox = new Box(4, 3, 4); boxes.Add(redBox, "red"); boxes.Add(blueBox, "blue"); Console.WriteLine(redBox.GetHashCode()); Console.WriteLine(blueBox.GetHashCode()); } catch (ArgumentException …

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

6
如何使用IEqualityComparer
我的数据库中有一些铃铛号相同。我希望所有这些都没有重复。我创建了一个compare类来完成这项工作,但是该函数的执行会导致该函数的延迟很大,没有区别,从0.6秒到3.2秒! 我做对了还是必须使用其他方法? reg.AddRange( (from a in this.dataContext.reglements join b in this.dataContext.Clients on a.Id_client equals b.Id where a.date_v &lt;= datefin &amp;&amp; a.date_v &gt;= datedeb where a.Id_client == b.Id orderby a.date_v descending select new Class_reglement { nom = b.Nom, code = b.code, Numf = a.Numf, }) .AsEnumerable() .Distinct(new Compare()) .ToList()); class Compare …
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.