TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
venus najad
1.3k
414
27.9k
How to sort a list with multiple parameters using CompareTo
Feb 19 2019 9:43 AM
hello... i have made a list of students, which contains name, age, grade and an annotation...
some of students has same name or some has same grade or some has same age...
when i run the program, it complains that the object is already exits...
my CompareTo method is as follow
public int CompareTo(Student other)
{
// If other is not a student
if (other == null)
{
throw new NotImplementedException();
throw new ArgumentException("Other is not a student");
}
// The comparison depends on the comparison of
// the underlying grade, age or name.
else if (this._name.CompareTo(other._name) > 1)
return other.OrderBy(s => s._name).ThenBy(s => s._age);
//return this._age.CompareTo(other._age);
else
return this._name.CompareTo(other._name);
}
it doesnt recognize OrderBy...
i appreciate any help... regards
Reply
Answers (
2
)
Abstraction query
property and class variable inside a loop