¡@

Home 

c# Programming Glossary: comparer

Distinct() with lambda?

http://stackoverflow.com/questions/1300088/distinct-with-lambda

myCustomerList.Distinct someEqualityComparer The equality comparer argument must be an instance of IEqualityComparer T . I can..

What is the best way to clone/deep copy a .NET generic Dictionary<string, T>?

http://stackoverflow.com/questions/139592/what-is-the-best-way-to-clone-deep-copy-a-net-generic-dictionarystring-t

which takes an existing IDictionary. You can specify the comparer as the existing dictionary's comparer too. If you do need to.. You can specify the comparer as the existing dictionary's comparer too. If you do need to clone the values you can use something..

Remove duplicates in the list using linq

http://stackoverflow.com/questions/1606679/remove-duplicates-in-the-list-using-linq

on only some of the properties create a custom equality comparer e.g. class DistinctItemComparer IEqualityComparer Item public..

LINQ - Fluent and Query Expression - Is there any benefit(s) of one over other? [closed]

http://stackoverflow.com/questions/214500/linq-fluent-and-query-expression-is-there-any-benefits-of-one-over-other

How to Count Duplicates in List with LINQ

http://stackoverflow.com/questions/454601/how-to-count-duplicates-in-list-with-linq

a list of some custom objects then you need to use custom comparer or group by specific property. Also query can't display result... that will be used in objects comparison or provide custom comparer. Here is an example Note that I use Foo.Name as a key i.e. objects..

Linq Distinct on a particular Property

http://stackoverflow.com/questions/489258/linq-distinct-on-a-particular-property

work and it now at least compiles . It assumes the default comparer for the keys though if you want to pass in an equality comparer.. for the keys though if you want to pass in an equality comparer just pass it on to the HashSet constructor. share improve this..

Why can't an anonymous method be assigned to var?

http://stackoverflow.com/questions/4965576/why-cant-an-anonymous-method-be-assigned-to-var

to var I have the following code Func string bool comparer delegate string value return value 0 However the following does.. return value 0 However the following does not compile var comparer delegate string value return value 0 Why can't the compiler.. it would lack consistency if I had the following var comparer delegate string arg1 string arg2 string arg3 string arg4 string..

Comparing Arrays in C#

http://stackoverflow.com/questions/713341/comparing-arrays-in-c-sharp

if a1.Length a2.Length return false EqualityComparer T comparer EqualityComparer T .Default for int i 0 i a1.Length i if comparer.Equals.. EqualityComparer T .Default for int i 0 i a1.Length i if comparer.Equals a1 i a2 i return false return true share improve this..

Merge two object lists with linq

http://stackoverflow.com/questions/720609/merge-two-object-lists-with-linq

are merged and doubles are removed. If you don't specify a comparer in the Union extension method like in my example it will use.. use the Name to compare two objects you can also write a comparer class which uses the IEqualityComparer interface. You can then.. the IEqualityComparer interface. You can then provide this comparer as the second parameter in the Linq extension Union method...

Use own IComparer<T> with Linq OrderBy

http://stackoverflow.com/questions/985657/use-own-icomparert-with-linq-orderby

x .ToList break this.Items items However the default comparer sorts as supposed like this 200906 1 200906 10 200906 11 200906.. this IComparer case ListSortDirection.Ascending MyComparer comparer new MyComparer items items.OrderByDescending x property.GetValue.. items items.OrderByDescending x property.GetValue x comparer .ToList break When I debug my code I see that MyComparer.Compare..

How would I sort a list of files by name to match how Windows Explorer displays them?

http://stackoverflow.com/questions/1012985/how-would-i-sort-a-list-of-files-by-name-to-match-how-windows-explorer-displays

06 02 4.0.11.txt 2009 06 02 4.0.12.txt I have a FileInfo Comparer that sorts an array of FileInfo objects by name class FileInfoComparer.. sorts an array of FileInfo objects by name class FileInfoComparer IComparer FileInfo public int Compare FileInfo x FileInfo y.. array of FileInfo objects by name class FileInfoComparer IComparer FileInfo public int Compare FileInfo x FileInfo y return string.Compare..

What's a good, generic algorithm for collapsing a set of potentially-overlapping ranges?

http://stackoverflow.com/questions/1233292/whats-a-good-generic-algorithm-for-collapsing-a-set-of-potentially-overlapping

Range T Collapse T this IEnumerable Range T me IComparer T comparer List Range T orderdList me.OrderBy r r.Start .ToList.. Range T Collapse T this IEnumerable Range T ranges IComparer T comparer if ranges null ranges.Any yield break if comparer.. null ranges.Any yield break if comparer null comparer Comparer T .Default var orderdList ranges.OrderBy r r.Start var firstRange..

Generics - where T is a number?

http://stackoverflow.com/questions/1267902/generics-where-t-is-a-number

operators for this you just need T x ... T y ... int c Comparer T .Default.Compare x y if c 0 x y else if c 0 x y share improve..

What's the most elegant way to bubble-sort in C#?

http://stackoverflow.com/questions/1595244/whats-the-most-elegant-way-to-bubble-sort-in-c

public void BubbleSort T IList T list BubbleSort T list Comparer T .Default public void BubbleSort T IList T list IComparer T.. Comparer T .Default public void BubbleSort T IList T list IComparer T comparer bool stillGoing true while stillGoing stillGoing..

Can I specify my explicit type comparator inline?

http://stackoverflow.com/questions/188120/can-i-specify-my-explicit-type-comparator-inline

foo1.key foo2.key. Rather than creating a new IEqualityComparer for the type can I simply specify the comparison inline using.. 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.. this question My MiscUtil library contains a ProjectionComparer to build an IComparer T from a projection delegate. It would..

how are nullable types implemented under the hood in .net?

http://stackoverflow.com/questions/2503811/how-are-nullable-types-implemented-under-the-hood-in-net

to null etc lifted operators in C# and in .NET via EqualityComparer T Comparer T etc special rules on generic type constraints to.. lifted operators in C# and in .NET via EqualityComparer T Comparer T etc special rules on generic type constraints to prevent Nullable..

Using Linq not equals

http://stackoverflow.com/questions/3669507/using-linq-not-equals

override of Equals GetHashCode Can you provide an IEqualityComparer Customer IEnumerable Customer resultsB listA.Except listB new.. Customer resultsB listA.Except listB new CustomerComparer Comparer shown below no override of Equals GetHashCode no IEqualityComparer.. Customer resultsB listA.Except listB new CustomerComparer Comparer shown below no override of Equals GetHashCode no IEqualityComparer..

Dynamic LINQ OrderBy on IEnumerable<T>

http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet

dynamic object source AccessorCache.GetAccessor property Comparer object .Default public static IOrderedEnumerable dynamic OrderByDescending.. dynamic object source AccessorCache.GetAccessor property Comparer object .Default public static IOrderedEnumerable dynamic ThenBy.. dynamic object source AccessorCache.GetAccessor property Comparer object .Default public static IOrderedEnumerable dynamic ThenByDescending..

Silverlight and ArrayList

http://stackoverflow.com/questions/4181800/silverlight-and-arraylist

to .NET programming including ArrayList Hashtable and Comparer. According to Inbar Gazit of Microsoft's Base Class Library.. The affected classes are ArrayList BitArray CaseInsensitiveComparer CaseInsensitiveHashCodeProvider CollectionBase Comparer CompatibleComparer.. CaseInsensitiveHashCodeProvider CollectionBase Comparer CompatibleComparer DictionaryBase EmptyReadOnlyDictionaryInternal..

Is there a Lower Bound function in C# on a SortedList?

http://stackoverflow.com/questions/594518/is-there-a-lower-bound-function-in-c-sharp-on-a-sortedlist

if list null throw new ArgumentNullException list var comp Comparer T .Default int lo 0 hi list.Length 1 while lo hi int m hi lo..

Sorting a list using Lambda/Linq to objects

http://stackoverflow.com/questions/722868/sorting-a-list-using-lambda-linq-to-objects

.NET framework is casting the lambda emp1 emp2 int as a Comparer Employee . This has the advantage of being strongly typed. ..

How do I create dynamic properties in C#?

http://stackoverflow.com/questions/947241/how-do-i-create-dynamic-properties-in-c

name return null set properties name value class Comparer T IComparer ObjectWithProperties where T IComparable string.. null set properties name value class Comparer T IComparer ObjectWithProperties where T IComparable string m_attributeName.. where T IComparable string m_attributeName public Comparer string attributeName m_attributeName attributeName public int..