往数组里添数据时如何改变数据的位置

  List<ScreenList> All = new List<ScreenList>();
                   
                if (string.IsNullOrEmpty(roomrowguid))
                {
                    ScreenList viewroom = new ScreenList();
                    viewroom.Key = "区域";
                    viewroom.Value = "roomtyperowguid";
                
                    var aa = _repositoryroomtype.GetAllList().OrderBy(e => e.Sort).FirstOrDefault();//默认第一个区域被选中
                    ScreenDetail detail1default = new ScreenDetail();
                    detail1default.Key = aa.TypeName;
                    detail1default.Value = aa.Id;
                    detail1default.IsChecked = true;
                    List<ScreenDetail> other = _repositoryroomtype.GetAllList().Where(e => e.Id != aa.Id).OrderBy(e => e.Sort).Select(e => new ScreenDetail
                    {  Key = e.TypeName,
                        Value = e.Id,
                        IsChecked = false
                    }).ToList();
                    other.Insert(0,detail1default);//把新添的数据放在第一条显示
                    viewroom.Lists = other;
                    All.Add(viewroom);
                    return Task.FromResult(All);

猜你喜欢

转载自www.cnblogs.com/cyqdeshenluo/p/12166909.html