Defines a generalized comparison method that a value type or class implements to create a type-specific comparison method for ordering instances.
Questions tagged [icomparable]
264 questions
-2
votes
2 answers
containing type does not implement interface 'System.IComparable' error
namespace Theprogram.cs
{
class Program
{
static void Main(string[] args)
{
CreditCustomer[] creditCustomer = new CreditCustomer[5];
int x, y;
bool goodNum;
for (x = 0; x <…

Daniel Robert
- 15
- 1
- 6
-2
votes
2 answers
comparable won't override abstract method
I have this method but it returns the error MyComparator is not abstract and does not overs the abstract method I have also tried using just Present instead of PresentInterface as I have already implemented the present interface in the present…

Amy
- 1
-2
votes
1 answer
C# - How can I call a method from another 'class ClassName where T : IComparable'
In my 'Program.cs' I am trying to call method 'inOrder()' from another class 'BinTree.cs'.
Class BinTree starts with class BinTree where T : IComparable
I've tried:
inOrder();
and
BinTree.inOrder();
and
BinTree.inOrder();
But none of…

BoggartBear
- 25
- 1
- 4
-2
votes
4 answers
Implementing IComparable
I am implmenting the IComparable to sort like typed objects. My question is why does it cast type person to int32? The array's Sort() seems to cast each type in the array to the type that I am using for comparison.
Comparable:
public class…

Nick
- 19,198
- 51
- 185
- 312
-2
votes
2 answers
Cannot cast from source to destination Type
im using a class called PriorityQueue and like the name says it should compare elements and ordain them this is the Comparer class inside priority Queue
private class DefaultComparer : IComparer
{
#region IComparer Members
…

Makenshi
- 993
- 3
- 15
- 28
-3
votes
1 answer
IComparable in WPF
I need to implement a Search button that will compare the value from my TextBox with the values in the arrays and if they match, it returns the index, otherwise it will return -1. I implemented the random arrays of double and int already as well as…

Victor Dallarosa
- 11
- 1
-4
votes
2 answers
Sort a sequence (a sub-array in a array) in decreasing order by their elements (elements in the sub-array of an array)
I have been trying for days to find a solution for this problem using c#. I was able to sort them by length but I cannot figure out the solution to sort the array by from their left-most to their right-most.
The hint they gave is to define a class…

Yo Yeah
- 3
- 2
-4
votes
1 answer
How to write Custom Comparator to check if two objects are equal
My requirement is I want to write custom Comparator library such that it can compare two objects return true if they are equal or false
for example
public interface Icomparator {
public boolean compare(X x, Y y);
}
public class…

Vikki Lohana
- 39
- 2
- 10
-7
votes
4 answers
Embedded statement error
I have a simple custom list class and I am trying to implement IComparable to it, but it's not working to be honest. I tried MSDN and other blogs and still same.
public class sortDateTime : IComparable
{
protected DateTime m_startDate,…

user2262511
- 101
- 10