Advertisement
Guest User

implementing compare() method in c# for a custom class

a guest
Dec 5th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. class Compare : IEqualityComparer<Process>
  2.     {
  3.         public bool Equals(Process x, Process y)
  4.         {
  5.             return x.ProcessName == y.ProcessName;
  6.         }
  7.  
  8.         public int GetHashCode(Process obj)
  9.         {
  10.             return obj.GetHashCode();
  11.         }
  12.     }
  13. ----------------
  14. and used like:
  15. var someTestList = latesProcessList.Except(snapShotList,new Compare()).ToList();
  16. and
  17. foreach (var item in latesProcessList.Except(snapShotList,new Compare()))
  18. {
  19.    item.Kill();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement