c# Programming Glossary: equalitycomparer
Implementing INotifyPropertyChanged - does a better way exist? http://stackoverflow.com/questions/1315621/implementing-inotifypropertychanged-does-a-better-way-exist SetField T ref T field T value string propertyName if EqualityComparer T .Default.Equals field value return false field value OnPropertyChanged..
Can I specify my explicit type comparator inline? http://stackoverflow.com/questions/188120/can-i-specify-my-explicit-type-comparator-inline like foo1.key foo2.key. Rather than creating a new IEqualityComparer for the type can I simply specify the comparison inline using.. Something like var f1 ... f2 ... var f3 f1.Except f2 new IEqualityComparer Foo a Foo b a.key.CompareTo b.key I'm pretty sure the above.. It would be the work of 10 minutes to make a ProjectionEqualityComparer to do the same thing. EDIT Here's the code for ProjectionEqualityComparer..
How to get index using LINQ? http://stackoverflow.com/questions/2471588/how-to-get-index-using-linq
How is List<T> implemented in C#? http://stackoverflow.com/questions/2540050/how-is-listt-implemented-in-c IndexOf T T array T value int startIndex int count return EqualityComparer T .Default.IndexOf array value startIndex count internal virtual..
Comparing 2 objects and retrieve a list of fields with different values http://stackoverflow.com/questions/3060382/comparing-2-objects-and-retrieve-a-list-of-fields-with-different-values type objects inbuilt IL equality equality operators and EqualityComparer T for the rest using System.Collections.Generic using System.Reflection.. eq null else il.EmitCall OpCodes.Call typeof EqualityComparer .MakeGenericType prop.PropertyType .GetProperty Default .GetGetMethod.. null il.EmitCall OpCodes.Callvirt typeof EqualityComparer .MakeGenericType prop.PropertyType .GetMethod Equals pp null..
c# compare two generic values [duplicate] http://stackoverflow.com/questions/488250/c-sharp-compare-two-generic-values indicate it is a reference type then foo bar is legal Use EqualityComparer T .Default to do it for you. This will not work on types which.. T T value1 GetValue2 T value2 GetValue1 return EqualityComparer T .Default.Equals valueInDB valueFromView If you do not restrict.. If you do not restrict to IEquatable T then the EqualityComparer default fallback may cause boxing when used with value types..
Why is there no Linq method to return distinct values by a predicate? http://stackoverflow.com/questions/520030/why-is-there-no-linq-method-to-return-distinct-values-by-a-predicate method in Linq that will do this just one that takes an IEqualityComparer . I can hack around it with this return myList.GroupBy x x.Url.. TKey keySelector return source.DistinctBy keySelector EqualityComparer TKey .Default public static IEnumerable TSource DistinctBy TSource.. IEnumerable TSource source Func TSource TKey keySelector IEqualityComparer TKey comparer if source null throw new ArgumentNullException..
Multi value Dictionary http://stackoverflow.com/questions/569903/multi-value-dictionary TFirst TSecond other if other null return false return EqualityComparer TFirst .Default.Equals this.First other.First EqualityComparer.. TFirst .Default.Equals this.First other.First EqualityComparer TSecond .Default.Equals this.Second other.Second public override.. TFirst TSecond public override int GetHashCode return EqualityComparer TFirst .Default.GetHashCode first 37 EqualityComparer TSecond..
What is the use of a static class http://stackoverflow.com/questions/576853/what-is-the-use-of-a-static-class
Comparing Arrays in C# http://stackoverflow.com/questions/713341/comparing-arrays-in-c-sharp a2 null return false if a1.Length a2.Length return false EqualityComparer T comparer EqualityComparer T .Default for int i 0 i a1.Length.. a2.Length return false EqualityComparer T comparer EqualityComparer T .Default for int i 0 i a1.Length i if comparer.Equals a1..
c# marking class property as dirty http://stackoverflow.com/questions/805505/c-sharp-marking-class-property-as-dirty void SetField T ref T field T value string propertyName if EqualityComparer T .Default.Equals field value field value IsDirty true OnPropertyChanged..
Overriding GetHashCode for mutable objects? [C#] http://stackoverflow.com/questions/873654/overriding-gethashcode-for-mutable-objects-c over time. Now most cases which use equality will take an IEqualityComparer T instance and use it for equality. In the cases where one is.. In the cases where one is not specified they will use EqualityComparer T .Default to find one. At worst case this will default to calling..
|