How do I implement my special ordering as CompareTo?

What about something like: public struct Foo : IComparable { public readonly int FirstLevel; public readonly int SecondLevel; public readonly int ThirdLevel; public readonly int FourthLevel; public int CompareTo(Foo other) { int result; if ((result = this.FirstLevel. CompareTo(other. FirstLevel))!

= 0) return result; else if ((result = this.SecondLevel. CompareTo(other. SecondLevel))!

= 0) return result; else if ((result = this.ThirdLevel. CompareTo(other. ThirdLevel))!

= 0) return result; else return this.FourthLevel. CompareTo(other. FourthLevel); } }.

1 (Foo other) can't be null - it's a struct, so no need to test for it. – Russell Troywest Nov 30 at 13:37 that came to my mind either ... additionally i'm just curious if I can somehow enhance & or sth alike ... – Andreas Niedermair Nov 30 at 13:40 @RussellTroywest, right, corrected. I had class in mind when I've been writing this.

– MichaÅ‚ Powaga Nov 30 at 13:40 @AndreasNiedermair it stops comparing just after it finds first difference so it looks fine for me, but I can't say that there's no better way. I just don't see it ;-). – MichaÅ‚ Powaga Nov 30 at 13:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions