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
Rich
NA
84
61.2k
Ranking items in a list with linq
Mar 14 2012 7:04 AM
I am trying to figure out a way to rank items in a list, and hold the results in an object or another list. I know about the orderby method, but I don't exactly know how to go about creating a corresponding rank number for each item. Is this possible with linq? For example:
List<int> numbers = new List();
numbers.Add(650);
numbers.Add(150);
numbers.Add(500);
numbers.Add(200);
and then store the results from either low to high or high to low here:
public class NumberRank
{
public int Number {get; set;}
public int Rank {get; set;}
public NumberRank(int number)
{
Number = number;
Rank = ????????;
}
}
Thanks, in advance.
Reply
Answers (
2
)
Simple login form with LINQ to Entities and C# 4.0
Nested GroupBy extension method