icomparer Questions

6

Solved

I have a generic List<MyClass> where MyClass has a property InvoiceNumber which contains values such as: 200906/1 200906/2 .. 200906/10 200906/11 200906/12 My list is bound to a Binding...
Pileate asked 12/6, 2009 at 8:49

4

Solved

I am using lambda expressions to sort and search an array in C#. I don't want to implement the IComparer interface in my class, because I need to sort and search on multiple member fields. class W...
Dylan asked 2/2, 2011 at 2:25

4

Solved

TL;DR I'm looking for a way to obtain IEqualityComparer<T> from IComparer<T>, no matter which datatype is T, including case-insensitive options if T is string. Or I need a different sol...
Bustee asked 15/6, 2015 at 17:12

2

Solved

I'm trying to implement the same example of this link but more oriented on the number of dependent kids. http://www.codeproject.com/Articles/42839/Sorting-Lists-using-IComparable-and-IComparer-Int...
Karolinekaroly asked 11/11, 2014 at 15:38

6

Solved

I have the following IComparer defined for boxed RegistryItem objects: public class BoxedRegistryItemComparer : IComparer<object> { public int Compare(object left, object right) { Registr...
Lilly asked 28/9, 2009 at 13:58

4

Solved

I am trying to use an IComparer to sort a list of Points. Here is the IComparer class: public class CoordinatesBasedComparer : IComparer { public int Compare(Object q, Object r) { Point a = (p)...
Gertrudgertruda asked 15/1, 2013 at 11:8

1

Solved

I'm fairly new to C# (6 months on the job experience), but it seems pretty similar to Java so I feel right at home. However, today I tried implementing the IComparer interface and wondered why it ...
Hasid asked 27/10, 2016 at 9:55

6

Solved

I am trying to solve this question: Write a function that finds the zero-based index of the longest run in a string. A run is a consecutive sequence of the same character. If there is more than one...
Conservatoire asked 12/11, 2015 at 13:54

8

Solved

I'm trying to figure out which of these interfaces I need to implement. They both essentially do the same thing. When would I use one over the other?
Guajardo asked 11/2, 2009 at 18:20

8

I happened to have seen some code where this guy passed a lambda expression to a ArrayList.Sort(IComparer here) or a IEnumerable.SequenceEqual(IEnumerable list, IEqualityComparer here) where an ICo...

3

Solved

Is it possible with C# to pass a lambda expression as an IComparer argument in a method call? eg something like var x = someIEnumerable.OrderBy(aClass e => e.someProperty, (aClass x, aClass y...
Unconformity asked 30/5, 2013 at 14:57

2

Solved

I am writing an IComparer<T> implementation by deriving from the Comparer<T> class, as recommended by MSDN. For example: public class MyComparer : Comparer<MyClass> { private re...
Kaylyn asked 11/3, 2016 at 12:33

2

Solved

How would an IComparer that needs an argument be implemented (might not be relevant but I'm using it on Linq query)? I suppose it should be called like this: ListOfObjectsToSort.orderBy(x => x...
Striper asked 29/1, 2015 at 22:11

1

Solved

What is the best practice in C# starting from version 4.0 when writing a comparer class : a. Should we inherit from Comparer abstract class ? or b. Should we implement IComparer interface. What ...
Kelcie asked 2/11, 2014 at 10:53

2

Solved

I have custom IComparer<string> which I use to compare strings ignoring their case and symbols like this: public class LiberalStringComparer : IComparer<string> { private readonly Comp...
Breakable asked 16/4, 2014 at 19:18

2

Solved

I'm implementing a custom comparer in order to apply a custom sort order for items in various views. Some of the time I'm finding that I want to maintain the existing order of items, in this case ...
Carcanet asked 8/4, 2013 at 15:28

4

Solved

My problem is that I always want to order a collection of objects in a certain fashion. For example: class foo{ public string name {get;set;} public DateTime date {get;set;} public int counter {g...
Curriculum asked 20/2, 2013 at 9:44

3

Solved

Ive just written the following code, which will order strings by their native string.Compare() but allow a collection of exceptions (in this case customPriority) that will place priority over the d...
Deprave asked 5/2, 2013 at 12:32

3

Solved

I want to use List.BinarySearch() with a custom item type. The custom type does not implement IComparable<T>; instead I have several static Comparison<T> functions that I call because a...
Featheredge asked 6/12, 2011 at 19:43

3

Solved

My question is about the IComparer interface, I never worked with it before, so I hope you can help me set up everything right. I have to use the interface to sort an list of own objects by the ex...
Rhaetic asked 13/12, 2012 at 12:4

6

What is the difference between IComparable and IComparer Interfaces? Is it necessary to use this interface always with Array.Sort() method
Compartment asked 12/5, 2011 at 15:51

1

Solved

I'm receiving a null object in my custom IComparer implementation despite no null entries in the collection it is being applied to. My understanding is this can be caused by inconsistencies in the ...
Plante asked 15/11, 2012 at 22:31

3

Solved

Could anyone explain me what's wrong in the following class declaration: private class PriorityQueueEntry<TPriorityValue,IIdentifiableEntry,IType> : IComparer<PriorityQueueEntry<TPrio...
Parang asked 13/11, 2012 at 12:44

1

Solved

I was reading a book about Linq, and saw that the Distinct method has an overload that takes a comparer. This would be a good solution to a problem I have where I want to get the distinct entities ...
Cythiacyto asked 11/11, 2012 at 14:23

2

Solved

Before I go reinventing the wheel, is there some framework way of creating an IComparer<T> from a Func<T,T,int>? EDIT IIRC (it's been a while) Java supports anonymous interface implem...
Lorentz asked 25/4, 2011 at 18:23

© 2022 - 2024 — McMap. All rights reserved.