• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Data.List类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Data.List的典型用法代码示例。如果您正苦于以下问题:C# List类的具体用法?C# List怎么用?C# List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



List类属于Data命名空间,在下文中一共展示了List类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RanksSort

        public List<Ranks> RanksSort(List<Ranks> ranks)
        {
            long count = ranks.Count;

            for (int i = 0; i < count - 1; i++)
                for (int j = 0; j < count - 1 - i; j++)
                {
                    if (ranks[j].Solved < ranks[j + 1].Solved)
                    {
                        long t = ranks[j].Position;
                        ranks[j].Position = ranks[j + 1].Position;
                        ranks[j + 1].Position = t;
                        Ranks rk = ranks[j];
                        ranks[j] = ranks[j + 1];
                        ranks[j + 1] = rk;
                    }
                    else if (ranks[j].Solved != 0 && ranks[j + 1].Solved != 0 && ranks[j].Solved == ranks[j + 1].Solved)
                    if(ranks[j].LastTimeOfAc > ranks[j + 1].LastTimeOfAc)
                    {
                        long t = ranks[j].Position;
                        ranks[j].Position = ranks[j + 1].Position;
                        ranks[j + 1].Position = t;
                        Ranks rk = ranks[j];
                        ranks[j] = ranks[j + 1];
                        ranks[j + 1] = rk;
                    }
                }

            return ranks;
        }
开发者ID:shakil0304003,项目名称:Local-Network-Programming-Contest,代码行数:30,代码来源:Ranks.cs


示例2: ReadIFeedItems

        public List<IFeedItem> ReadIFeedItems(Uri uri)
        {
            var feedItems = new List<Data.IFeedItem>();
            SyndicationFeed syndicationFeed;
            using (var xmlReader = XmlReader.Create(uri.AbsoluteUri))
            {
                syndicationFeed = SyndicationFeed.Load(xmlReader);
                xmlReader.Close();
            }

            foreach (var item in syndicationFeed.Items)
            {
                var feedItem = new FeedItem();
                var id = Guid.NewGuid();
                feedItem.Id = Guid.TryParse(item.Id, out id) ? new Guid(item.Id) : id;
                feedItem.Title = item.Title.Text;
                feedItem.Mp3Url = item.Links[0].Uri;
                feedItem.PublishDate = item.PublishDate.DateTime;

                feedItems.Add(feedItem);
            }

            var ret = new List<IFeedItem>();
            feedItems.ForEach(x => ret.Add(new FeedItem() { Id = x.Id, Mp3Url = x.Mp3Url, PublishDate = x.PublishDate, Title = x.Title }));
            return ret;
        }
开发者ID:kimdah3,项目名称:CSharpProjectLarsKimLinus,代码行数:26,代码来源:RssReader.cs


示例3: actualizarSectoresEdificio

        public static void actualizarSectoresEdificio(edificio edificio, List<sector> sectores)
        {
            try {
                admEntities db = Datos.getDB();
                var s = db.edificios_sectores.Where(x => x.dir_edificio == edificio.direccion).ToList();

                foreach (var sectB in s)
                {
                    db.edificios_sectores.Remove(sectB);
                }

                foreach (sector sect in sectores)
                {
                    edificios_sectores es = new edificios_sectores();
                    es.dir_edificio = edificio.direccion;
                    es.id_sector = sect.idsector;
                    db.edificios_sectores.Add(es);
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                string str = e.InnerException == null ? e.Message : e.InnerException.Message;
                Logger.Log.write(str);
                throw e;
            }
        }
开发者ID:fedec93,项目名称:Administracion,代码行数:27,代码来源:CatalogoSectores.cs


示例4: ValidateFields

 /// <summary>
 /// Validates the field values of this object. Override this method to enable
 /// validation of field values.
 /// </summary>
 /// <param name="validationResults">The validation results, add additional results to this list.</param>
 protected override void ValidateFields(List<IFieldValidationResult> validationResults)
 {
     if (string.IsNullOrWhiteSpace(Name))
     {
         validationResults.Add(FieldValidationResult.CreateError(NameProperty, "Name of room is required"));
     }
 }
开发者ID:BartekDuszynski,项目名称:Catel.Examples,代码行数:12,代码来源:RoomModel.cs


示例5: StatC5CX

        public void StatC5CX(List<DwNumber> numbers, string dbName)
        {
            string[] dmNames = new string[] { "Peroid", "He" };
            string[] numberTypes = new string[] { "A2", "A3", "A4", "A6", "A7", "A8" };
            DwC5CXSpanBiz spanBiz = new DwC5CXSpanBiz(dbName);

            foreach (var numberType in numberTypes)
            {
                Dictionary<string, Dictionary<string, int>> lastSpanDict = new Dictionary<string, Dictionary<string, int>>(16);
                List<DwC5CXSpan> c5cxSpans = new List<DwC5CXSpan>(numbers.Count * 20);
                string newNumberType = numberType.Replace("A", "C");
                string tableName = string.Format("{0}{1}", "C5", newNumberType);
                spanBiz.DataAccessor.TableName = ConfigHelper.GetDwSpanTableName(tableName);
                long lastP = spanBiz.DataAccessor.SelectLatestPeroid(string.Empty);

                foreach (DwNumber number in numbers)
                {
                    var cxNumbers = NumberCache.Instance.GetC5CXNumbers(number.C5, newNumberType);
                    var c5cxSpanList = this.GetC5CXSpanList(lastSpanDict, cxNumbers, number, dmNames);
                    if (number.P > lastP)
                        c5cxSpans.AddRange(c5cxSpanList);
                }
                spanBiz.DataAccessor.Insert(c5cxSpans, SqlInsertMethod.SqlBulkCopy);

                Console.WriteLine("{0} {1} Finished", dbName, tableName);
            }

            Console.WriteLine("{0} {1} Finished", dbName, "ALL C5CX Span");
        }
开发者ID:tavenli,项目名称:gaopincai,代码行数:29,代码来源:DmSpan.cs


示例6: getAllStaff

 public static List<Staff> getAllStaff()
 {
     List<Staff> StaffsList = new List<Staff>();
     //Connect to SQL Server
     SqlConnection conn = new SqlConnection("Data Source=(local); Database=WebDevelopmentDB; Integrated Security=SSPI");
     //Select all columns for a given StaffID as well as their password hash
     SqlCommand cmd = new SqlCommand("SELECT dbo.Staff.GivenName, dbo.Staff.Surname, dbo.Staff.Email, dbo.Staff.PhoneNumber1, dbo.Staff.PhoneNumber2, dbo.Staff.Role, dbo.Accounts.PassHash FROM dbo.Staff INNER JOIN dbo.Accounts ON dbo.Staff.StaffID = dbo.Accounts.AccID)", conn);
     SqlDataReader rdr = cmd.ExecuteReader();
     while (rdr.Read()) {
         StaffsList.Add(new Staff{
         GivenName = rdr[0].ToString(),
         Surname = rdr[1].ToString(),
         Address = rdr[2].ToString(),
         Email = rdr[3].ToString(),
         Phone1 = rdr[4].ToString(),
         Phone2 = rdr[5].ToString(),
         Role = rdr[6].ToString(),
         PassHash = rdr[7].ToString()});
     }
     //Close the reader and the SQL connection
     if (rdr != null) {
         rdr.Close();
     }
     conn.Close();
     return StaffsList;
 }
开发者ID:KirbySugden-Ware,项目名称:INB373,代码行数:26,代码来源:StaffList.cs


示例7: ValidateFields

 /// <summary>
 /// Validates the field values of this object. Override this method to enable
 /// validation of field values.
 /// </summary>
 /// <param name="validationResults">The validation results, add additional results to this list.</param>
 protected override void ValidateFields(List<IFieldValidationResult> validationResults)
 {
     if (string.IsNullOrWhiteSpace(ApiKey))
     {
         validationResults.Add(FieldValidationResult.CreateError(ApiKeyProperty, "Api key is required"));
     }
 }
开发者ID:BartekDuszynski,项目名称:Catel.Examples,代码行数:12,代码来源:ProvideAnalyticsViewModel.cs


示例8: GetFarFromOneRelations

        public static List<UserProfile> GetFarFromOneRelations(Guid userId)
        {
            // On cherche nos relations. On cherche les relations de nos relations => récursif
            List<UserProfile> listUserRelations = GetRelations(userId);

            List<UserProfile> listLoggedUserRelation = GetRelations((Guid)(Membership.GetUser(System.Web.HttpContext.Current.User.Identity.Name, false).ProviderUserKey));

            List<UserProfile> listFarFromOneRelations = new List<UserProfile>();

            // We search all the directly connected users to the actual logged user relations
            foreach (UserProfile userRelation in listUserRelations)
            {
                listFarFromOneRelations.AddRange(GetRelations((Guid)(Membership.GetUser(userRelation.UserName, false).ProviderUserKey)));
            }

            UserProfile actualUser = UserProfile.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name);
            while(listFarFromOneRelations.Contains(actualUser))
            {
                // We delete all the occurences of the actual user
                listFarFromOneRelations.Remove(actualUser);
            }

            // On supprime les utilisateurs qui sont déjà directement connectés avec l'utilisateur
            foreach (UserProfile user in listLoggedUserRelation)
            {
                if (listFarFromOneRelations.Contains(user))
                {
                    listFarFromOneRelations.Remove(user);
                }
            }

            return listFarFromOneRelations;
        }
开发者ID:remimarenco,项目名称:BindedIn,代码行数:33,代码来源:RelationService.cs


示例9: Create

        public static IRepository<Book> Create()
        {
            var listOfBooks = new List<Book>();
            for (int i = 0; i < 20; i++)
            {
                listOfBooks.Add(new Book
                {
                    Id = i,
                    Title = "Book " + i,
                    Description = "Description" + i,
                    Author = new Author
                    {
                        FirstName = "FirstName " + i,
                        LastName = "LastName " + i
                    }
                });
            }

            var repository = new Mock<IRepository<Book>>();
            repository.Setup(r => r.All()).Returns(listOfBooks.AsQueryable());
            repository.Setup(r => r.Add(It.IsAny<Book>())).Callback<Book>(b =>
            {
                b.Id = 1;
            });
            repository.Setup(r => r.SaveChanges()).Verifiable();

            return repository.Object;
        }
开发者ID:rahulchrty,项目名称:MyTested.WebApi,代码行数:28,代码来源:BooksRepositoryMock.cs


示例10: btnCobrar_Click

        private void btnCobrar_Click(object sender, EventArgs e)
        {
            List<CatalogoDeudores.DetalleDeuda> detalles = new List<CatalogoDeudores.DetalleDeuda>();

            foreach (DataGridViewRow r in dgvLista.Rows)
            {
                if (r.Cells["Seleccion"].Value != null)
                {
                    CatalogoDeudores.DetalleDeuda d = ((CatalogoDeudores.DetalleDeuda)r.DataBoundItem);
                    Business.ControladorExpensas.registrarPago(d);
                    detalles.Add(d);
                }
            }

            if (detalles.Count > 0)
            {
                if (MessageBox.Show("Desea imprimir comprobante?", "Sistema", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    unidad u = (unidad)cmbUnidad.SelectedItem;
                    titular t = u.titular;

                    System.Diagnostics.Process.Start(Business.ControladorExpensas.emitirRecibo(Properties.Resources.qr, detalles, u, t));
                }
            }

            cmbUnidad_SelectedIndexChanged(sender, e);
            lblImporte.Text = lblRecargo.Text = lblTotalAPagar.Text = "0,00";
        }
开发者ID:fedec93,项目名称:Administracion,代码行数:28,代码来源:PagoManual_V2.cs


示例11: Deserialise

        public void Deserialise(Reader In)
        {
            Bookings = new List<Booking>(In.ReadInt32());
            for (int x = 0; x < Bookings.Capacity; x++)
                Bookings.Add(DataModel.DeserialiseExternal<Booking>(In));

            Departments = new List<Department>(In.ReadInt32());
            for (int x = 0; x < Departments.Capacity; x++)
                Departments.Add(DataModel.DeserialiseExternal<Department>(In));

            Periods = new List<TimeSlot>(In.ReadInt32());
            for (int x = 0; x < Periods.Capacity; x++)
                Periods.Add(DataModel.DeserialiseExternal<TimeSlot>(In));

            Rooms = new List<Room>(In.ReadInt32());
            for (int x = 0; x < Rooms.Capacity; x++)
                Rooms.Add(DataModel.DeserialiseExternal<Room>(In));

            Users = new List<User>(In.ReadInt32());
            for (int x = 0; x < Users.Capacity; x++)
                Users.Add(DataModel.DeserialiseExternal<User>(In));

            Subjects = new List<Subject>(In.ReadInt32());
            for (int x = 0; x < Subjects.Capacity; x++)
                Subjects.Add(DataModel.DeserialiseExternal<Subject>(In));

            Classes = new List<Class>(In.ReadInt32());
            for (int x = 0; x < Classes.Capacity; x++)
                Classes.Add(DataModel.DeserialiseExternal<Class>(In));
        }
开发者ID:hnefatl,项目名称:Prototype1,代码行数:30,代码来源:DataSnapshot.cs


示例12: C5CX

        public static void C5CX(string name, string type, int length, string output)
        {
            List<DmDPC> srcNumbers = null;
            if (length > 5)
            {
                srcNumbers = NumberCache.Instance.GetNumberList(type);
            }
            else
            {
                srcNumbers = NumberCache.Instance.GetNumberList("C5");
            }

            DmC5CXBiz biz = new DmC5CXBiz(name);
            List<DmC5CX> entities = new List<DmC5CX>(srcNumbers.Count * 56);
            foreach (var srcNumber in srcNumbers)
            {
                string number = srcNumber.Number.Replace(' ', ',');
                var cxNumbers = new Combinations<int>(number.ToList(), length > 5 ? 5 : length);
                foreach (var cxNumber in cxNumbers)
                {
                    string cx = NumberCache.Instance.GetNumberId(length > 5 ? "C5" : type, cxNumber.Format("D2", ","));
                    DmC5CX entity = new DmC5CX();
                    entity.C5 = (length > 5) ? cx : srcNumber.Id;
                    entity.CX = (length > 5) ? srcNumber.Id : cx;
                    entity.C5Number = (length > 5) ? cx.ToString(2, " ") : srcNumber.Number;
                    entity.CXNumber = (length > 5) ? srcNumber.Number : cx.ToString(2, " ");
                    entity.NumberType = type;
                    entities.Add(entity);
                }
            }

            //biz.DataAccessor.Truncate();
            biz.DataAccessor.Insert(entities, SqlInsertMethod.SqlBulkCopy);
        }
开发者ID:tomdeng,项目名称:gaopincai,代码行数:34,代码来源:ImportDmDPC.cs


示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            List<recommandation> listR = new List<recommandation>();

            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;

                //on recupere le parametre "del" pour voir si il y a un message à effacer
                if (Request.Params["del"] != null && Convert.ToInt16(Request.Params["del"]) != 0)
                {
                    //RecommandationService.deleteRecommandation(Convert.ToInt16(Request.Params["del"]),2);
                    not.Text = "Recommandation effacée";
                }

                listR = RecomendationService.getRecommandations((Guid)Membership.GetUser(userName, false).ProviderUserKey);
                if (listR.Count > 0)
                {
                    //o utilise le template pour les messages envoyés
                    rpt.DataSource = RecomendationService.RecommandationToRecommandationPlus(listR);
                    rpt.DataBind();
                }
                else
                {
                    errorMessage("Aucune recommandation à afficher");
                }

            }
            else
            {
                errorMessage("Erreur");
            }
        }
开发者ID:remimarenco,项目名称:BindedIn,代码行数:33,代码来源:Recommandation.aspx.cs


示例14: Span

 private void Span(List<DwNumber> numbers)
 {
     string[] dxs = { "D1", "D2", "D3", "D4", "D5" };
     var spanDict = new Dictionary<int, int>(11);
     StreamWriter sw = new StreamWriter(@"d:\c1span.txt", false, Encoding.UTF8);
     foreach (var number in numbers)
     {
         foreach (var dx in dxs)
         {
             int spans = number.Seq - 1;
             int dxValue = ConvertHelper.GetInt32(number[dx].ToString());
             if (spanDict.ContainsKey(dxValue))
             {
                 spans = number.Seq - spanDict[dxValue] - 1;
                 spanDict[dxValue] = number.Seq;
             }
             else
             {
                 spanDict.Add(dxValue, -1);
             }
             sw.WriteLine("{0},{1},{2}", number.P, dxValue, spans);
         }
     }
     sw.Close();
 }
开发者ID:tomdeng,项目名称:gaopincai,代码行数:25,代码来源:C1Stat.cs


示例15: getAllExpensas

        public static List<ExpensasEdificio> getAllExpensas(List<edificio> edificios, DateTime periodo, DateTime vto1, DateTime vto2)
        {
            try
            {
                List<ExpensasEdificio> expensas = new List<ExpensasEdificio>();
                admEntities db = Datos.getDB();

                //var edificios = db.edificio.ToList();
                int MaxNroFactura = 0;
                List<string> nroFactura = db.Database.SqlQuery<String>(@"select nro_factura from expensas").ToList();
                foreach (var s in nroFactura)
                {
                    int temp = int.Parse(s);
                    if (temp > MaxNroFactura)
                        MaxNroFactura = temp;
                }

                int correlativo = MaxNroFactura + 1;

                DateTime asd = DateTime.Parse("1 /" + periodo.Month + "/" + periodo.Year);
                List<expensas> expensasExistentes = db.expensas.Where(x => x.fecha == asd).ToList();

                foreach (var e in edificios)
                {
                    expensas.Add(getExpensasEdificio(e, periodo, vto1, vto2, ref correlativo, db, expensasExistentes));
                }
                return expensas;
            }
            catch (Exception e)
            {
                Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
                throw e;
            }
        }
开发者ID:fedec93,项目名称:Administracion,代码行数:34,代码来源:CatalogoExpensas.cs


示例16: CategorySettingsForm

 public CategorySettingsForm(List<Category> categories, List<IFeed> allFeeds)
 {
     InitializeComponent();
     this.Categories = categories;
     this.AllFeeds = allFeeds;
     IsCategoriesChanged = false;
 }
开发者ID:kimdah3,项目名称:CSharpProjectLarsKimLinus,代码行数:7,代码来源:CategorySettingsForm.cs


示例17: Index

        // GET: Matching
        public ActionResult Index()
        {
            //Check if user is logged in
            if (!PageAuthorization.Authorize()) return RedirectToAction("Login", "Users");

            //User user = new User();
            //user.Id = 72;
            var user = (User)Session["logged_in_user_obj"];

            var client = new SMARestClient("MeetUpService.svc");
            var meetupContent = client.Get<List<MeetUp>>("meetups/").ToList();
            List<MeetUp> received = new List<MeetUp>();
            List<MeetUp> sent = new List<MeetUp>();

            foreach (var item in meetupContent)
            {
                if (item.Guide.Id == user.Id)
                {
                    received.Add(item);
                }
            }

            foreach (var item in meetupContent)
            {
                if (item.Traveler.Id == user.Id)
                {
                    sent.Add(item);
                }
            }

            ViewBag.ReceivedRequest = received;
            ViewBag.SentRequest= sent;
            return View();
        }
开发者ID:valorl,项目名称:ShowMeAround,代码行数:35,代码来源:MeetUpController.cs


示例18: Build

        public static Game Build()
        {
            var hidingSpots = new List<HidingSpot>();

            var rnd = new Random();
            var indexOfHidingSpot = rnd.Next(9);

            for (var idx = 0; idx < 9; idx++)
            {
                hidingSpots.Add(new HidingSpot
                {
                    Id = idx,
                    HasBeenChecked = false,
                    HasTreasure = idx == indexOfHidingSpot
                });
            }

            _game = new Game
            {
                Id = 1,
                TurnsRemaining = 3,
                HidingSpots = hidingSpots
            };

            return _game;
        }
开发者ID:darcy-buttrose,项目名称:relay-treasurehunt-dotnet,代码行数:26,代码来源:GameBuilder.cs


示例19: getClasses

 public static List<Class> getClasses(string student)
 {
     List<Class> classList = new List<Class>();
     //Connect to SQL Server
     SqlConnection conn = new SqlConnection("Data Source=PANDORASBOX\\PANDORASBOX; Database=WebDevelopmentDB; Integrated Security=SSPI");
     conn.Open();
     ClassRoster roster = new ClassRoster(int.Parse(student));
     //Select all columns for a given StaffID as well as their password hash
     for (int i = 0; i <= roster.Roster.GetLength(0); i++) {
         SqlCommand cmd = new SqlCommand("SELECT ClassCode, Day, Time, Semester, TutorID FROM dbo.ClassList WHERE (ClassCode = " + roster.Roster[i, 0] + ")", conn);
         SqlDataReader rdr = cmd.ExecuteReader();
         while (rdr.Read()) {
             classList.Add(new Class {
                 ClassCode = rdr[0].ToString(),
                 Day = rdr[1].ToString(),
                 Time = rdr[2].ToString(),
                 Semester = rdr[3].ToString(),
                 TutorID = rdr[4].ToString()
             });
         }
         //Close the reader and the SQL connection
         if (rdr != null) {
             rdr.Close();
         }
         conn.Close();
     }
     return classList;
 }
开发者ID:KirbySugden-Ware,项目名称:INB373,代码行数:28,代码来源:ClassList.cs


示例20: Them

 public int Them(BOXuLyKho item, List<BOXuLyKhoChiTiet> lsArray, Transit mTransit)
 {
     ThemMoi(item, lsArray, mTransit);
     frmXuLyKho.AddObject(item.XuLyKho);
     frmXuLyKho.Commit();
     return item.XuLyKho.ChinhKhoID;
 }
开发者ID:MisterTobi,项目名称:restaurant-cafe,代码行数:7,代码来源:BOXuLyKho.cs



注:本文中的Data.List类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BLL.TriglavBL类代码示例发布时间:2022-05-24
下一篇:
C# DarkMultiPlayerServer.ClientObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap