IComparable <T> does not implement
I changed from using IComparable to IComparable<Artist> however I get an error
'RecordCollection.Artist' does not implement a member of the 'System.IComparable.CompareTo (object)' interface
class Artist : IComparable<Artist> I added the CompareTo method.
Not sure what this error means, any help describing why I get this would be great.
class Artist : IComparable<Artist> { private String Name; private int NoMem; public Artist(string Name, int NoMem) { this.Name = Name; this.NoMem = NoMem; } public int CompareTo(Artist other) { if (other == null) return 1; else return 0; } } New Tree AVL Artist
AVLTree<Artist> treeAVL = new AVLTree<Artist>(); You must ensure that your project in which you define Artist compiles without errors. Otherwise, your other projects will not pick up the changes and still think that Artist implements IComparable instead of IComparable<T> . This is when you get a compile time error:
'RecordCollection.Artist' does not implement a member of the 'System.IComparable.CompareTo (object)' interface
There is no need for technical support for CompareTo(object) , and this will not solve your problem.
Message:
'RecordCollection.Artist' does not implement a member of the 'System.IComparable.CompareTo (object)' interface
clearly states that it thinks your class is still declaring that it implements IComparable . You may want to find this (it may be in another file through a partial class ). However, I personally consider it appropriate to include unprintable support. I would just add:
int IComparable.CompareTo(object obj) { return CompareTo(obj as Artist); }