Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have list of user with time.
i give orderby on time.

now i want to append one more record at first position.but it add at last of list.

What I have tried:

selectedusr = roomList.Where(x => x.Username == hdnRoomName.Value).FirstOrDefault();

roomListtemp = roomList.OrderByDescending(x => x.UpdatedAt).Take(9).ToList();  
             
roomListtemp.Add(selectedusr);



now new roomlisttemp have add new value at last but i want it requried at 1st potion.
Posted
Updated 19-Sep-17 1:30am

1 solution

List(T).Insert Method (Int32, T) (System.Collections.Generic)[^]
C#
roomListtemp.Insert(0, selectedusr);
 
Share this answer
 
v2
Comments
Jaydeep Shah 19-Sep-17 8:05am    
Thank you so much @Graeme_Grant
Graeme_Grant 19-Sep-17 8:06am    
You are welcome.

I have a question for you... Any reason for unaccepting the answer? By accepting it is a clear signal to others that it worked for you.
Jaydeep Shah 19-Sep-17 11:07am    
i accept your answer that time but i don't know why it's happens rejected !!
i think i click double that's why.
Graeme_Grant 19-Sep-17 17:43pm    
All good. Thanks for following up. :)

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