使用lambda exp将数据添加到现有列表 [英] Add data to existing list using lambda exp
本文介绍了使用lambda exp将数据添加到现有列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有时间用户列表。
i按时提供订单。
现在我想在第一个位置添加一个记录。但它会在列表的最后添加。< br $> b $ b
我尝试过:
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);
现在新的roomlisttemp有最后添加新值,但我希望它在第一部分处理。
now new roomlisttemp have add new value at last but i want it requried at 1st potion.
推荐答案
List(T).Insert Method(Int32,T)(System.Collections.Generic) [ ^ ]
List(T).Insert Method (Int32, T) (System.Collections.Generic)[^]
roomListtemp.Insert(0, selectedusr);
这篇关于使用lambda exp将数据添加到现有列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文