Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all,
I am trying to create 2 functions in C# and ASP.net
I have a table which has about 50 records. I has a column that hold integer let say 50 down to 0.

So i created an ILIST but instead of foreach statement I need the one that is closest to 0. I have the hibernate statement that gets the ILIST and sort them accordingly. So now I need to only pull the first record the one closest to 0.


I also need to due the same with a record closest to today date using a column that hold a due date.

Never did this before so any help and detailed instruction would be helpfull
Any and all help please will be appreciated????

Thanks to all.
Posted
Comments
Sergey Alexandrovich Kryukov 15-Jan-12 0:04am    
Where did you get such type -- ILIST? Remember, C# is case-sensitive.
--SA

1 solution

You can retrieve the first element of the sorted list.


For sorting the elements of an IList you can use the OrderBy method.


For retrieving the first element of an IList you can use the First or the FirstOrDefault methods.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900