当前位置: 首页>>代码示例>>C#>>正文


C# List.Add方法代码示例

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


在下文中一共展示了List.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateListPatient

        /// <summary>
        /// crée une liste de 5 patients
        /// </summary>
        /// <returns>la liste de patients</returns>
        public List<Dbo.Patient> CreateListPatient()
        {
            Observation obs = new Observation();
            List<Dbo.Patient> res = new List<Dbo.Patient>();

            Dbo.Patient patient1 = new Dbo.Patient()
            {
                Firstname = "laurence",
                Name = "marshall",
                Id = 1,
                Birthday = new DateTime(1986, 06, 30),
                Observations = obs.CreateListObservation()
            };

            Dbo.Patient patient2 = new Dbo.Patient()
            {
                Firstname = "laure",
                Name = "sagem",
                Id = 2,
                Birthday = new DateTime(1950, 06, 30),
                Observations = obs.CreateListObservation()
            };

            Dbo.Patient patient3 = new Dbo.Patient()
            {
                Firstname = "phillip",
                Name = "logy",
                Id = 3,
                Birthday = new DateTime(1970, 10, 25),
                Observations = obs.CreateListObservation()
            };

            Dbo.Patient patient4 = new Dbo.Patient()
            {
                Firstname = "sebastien",
                Name = "risette",
                Id = 4,
                Birthday = new DateTime(1965, 05, 01),
                Observations = obs.CreateListObservation()
            };

            Dbo.Patient patient5 = new Dbo.Patient()
            {
                Firstname = "thomas",
                Name = "gallente",
                Id = 5,
                Birthday = new DateTime(1932, 12, 25),
                Observations = obs.CreateListObservation()
            };

            res.Add(patient1);
            res.Add(patient2);
            res.Add(patient3);
            res.Add(patient4);
            res.Add(patient5);

            return res;
        }
开发者ID:chahla,项目名称:wpf-medical,代码行数:62,代码来源:Patient.cs

示例2: MergeFiles

        public static void MergeFiles(Repository repo)
        {
            var f1 = repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.UniqueEmailAddressesFilename;
            var f2 = repo.StorageWrapper.Data.MineableDataDirectory + Extractor.LinkedInFilename;
            var f3 = repo.StorageWrapper.Data.MineableDataDirectory + Extractor.IgnoreListFilename;

            if (!File.Exists(f1))
            {
                Console.WriteLine("Unable to locate " + f1);
                return;
            }

            if (!File.Exists(f2))
            {
                Console.WriteLine("Unable to locate " + f2);
                return;
            }

            if (!File.Exists(f3))
            {
                Console.WriteLine("Unable to locate " + f3);
                return;
            }

            var mozilla = File.ReadLines(f1).ToList();
            var linkedIn = File.ReadLines(f2).ToList();
            var ignore = File.ReadLines(f3).ToList();
            var final = new List<string>();

            foreach (var line in mozilla.Where(line => !final.Contains(line.ToLower())).Where(line => ignore.All(ignorePart => !line.ToLower().Contains(ignorePart.ToLower()))))
            {
                final.Add(line.ToLower());
            }
            foreach (var line in linkedIn.Where(line => !final.Contains(line.ToLower())).Where(line => ignore.All(ignorePart => !line.ToLower().Contains(ignorePart.ToLower()))))
            {
                final.Add(line.ToLower());
            }

            final.Sort();

            File.WriteAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename, final);

            var domains = final.Where(x => x.Contains('@')).Select(x => x.Split('@')[1]).Distinct().ToList();

            domains.Sort();

            File.WriteAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.UniqueDomainsFilename, domains);

            if (UIRetriever.GetBool(String.Format("View {0}?", Extractor.ConvergedEmailAddressesFilename)))
            {
                FileVisualiser.Show(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename);
            }

            if (UIRetriever.GetBool(String.Format("View {0}?", repo.StorageWrapper.Data.MineableDataResultsDirectory)))
            {
                DirectoryVisualiser.ShowFile(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename);
            }
        }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:58,代码来源:FileMerger.cs

示例3: GetInteressingPhrases

        public List<SensiumResultPhrase> GetInteressingPhrases(string inputText)
        {
            List<SensiumResultPhrase> returnedPhrases = new List<SensiumResultPhrase>();

            using (var client = new WebClient())
            {
                try
                {
                    client.Headers[HttpRequestHeader.ContentType] = "application/json";
                    client.Headers[HttpRequestHeader.Accept] = "application/json";

                    string toupload = "{" +
                                        "\"apiKey\": \"c105f2f6-ca21-4ddb-ab36-480cf438b6f3\"," +
                                        "\"text\": \"" + inputText + "\"," +
                                        "\"extractors\": [ \"Summary\", \"Entities\" ]" +
                                      "}";

                    var response = client.UploadData("https://api.sensium.io/v1/extract", Encoding.UTF8.GetBytes(toupload));

                    var responseString = Encoding.UTF8.GetString(response);
                    dynamic obj = JsonConvert.DeserializeObject(responseString);

                    //keyphrases extraction here
                    foreach (var ph in obj.summary.keyPhrases)
                    {
                        if (!Utilities.Helper.SensiumResultListContainsText(returnedPhrases, ph.text.ToString()))
                        {
                            SensiumResultPhrase phrase = new SensiumResultPhrase();
                            phrase.Text = ph.text.ToString();
                            phrase.Score = Double.Parse(ph.score.ToString());
                            phrase.Type = "phrase";

                            returnedPhrases.Add(phrase);
                        }
                    }

                    //Named entity extraction here
                    foreach (var ent in obj.entities)
                    {
                        SensiumResultPhrase phrase = new SensiumResultPhrase();
                        phrase.Text = ent.normalized.ToString();
                        phrase.Score = 1;

                        returnedPhrases.Add(phrase);
                    }

                }
                catch (WebException ex)
                {
                   //s var resp = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();

                  //  Logger.LogError(resp);

                }

                return returnedPhrases;
            }
        }
开发者ID:Alymcgeel,项目名称:ContextSearchHelper,代码行数:58,代码来源:SensiumConnector.cs

示例4: GenerateFakeCollectionOfGames

        private IEnumerable<Game> GenerateFakeCollectionOfGames()
        {
            var games = new List<Game>();
            var fakeGame = new Game(new GameField(5, 5));
            fakeGame.Id = "FakeId";

            games.Add(fakeGame);
            games.Add(new Game(new GameField(10, 10)));
            games.Add(new Game(new GameField(15, 15)));

            return games;
        }
开发者ID:Baloons-Pop-3,项目名称:Baloons-Pop-Three,代码行数:12,代码来源:MockIContext.cs

示例5: AfterImport

        public void AfterImport(IList added, IList updated)
        {
            if (GlobalSettings.runAfterImport)
            {
                var activities = new List<IActivity>();

                foreach (object record in added)
                {
                    if (record is IActivity)
                    {
                        activities.Add(record as IActivity);
                    }
                }

                foreach (object record in updated)
                {
                    if (record is IActivity)
                    {
                        activities.Add(record as IActivity);
                    }
                }

                GlobalSettings.LoadSettings();

                if (GlobalSettings.calculateFutureAfterImport)
                {
                    DateTime oldestActivity = DateTime.MaxValue;

                    foreach (IActivity activity in activities)
                    {
                        if (activity.StartTime < oldestActivity)
                        {
                            oldestActivity = activity.StartTime;
                        }
                    }

                    foreach (IActivity activity in CalculatedFields.GetLogBook().Activities)
                    {
                        if (activity.StartTime >= oldestActivity)
                        {
                            if (!activities.Contains(activity))
                            {
                                activities.Add(activity);
                            }
                        }
                    }
                }

                Evaluator.Calculate(activities, null, false);
            }
        }
开发者ID:gerhardol,项目名称:calculatedfields,代码行数:51,代码来源:ExtendImport.cs

示例6: Session

        public Session(Timer timer, IEnumerable<string> portStrings)
        {
            List<string> textPortStrings = new List<string>();
            List<string> yarpPortStrings = new List<string>();
            List<string> rosPortStrings = new List<string>();

            foreach (string portString in portStrings)
            {
                if (portString.Length < 2) throw new InvalidOperationException("\"" + portString + "\" is not a valid port string");

                switch (portString.Substring(0, 2))
                {
                    case "t:": textPortStrings.Add(portString.Substring(2)); break;
                    case "y:": yarpPortStrings.Add(portString.Substring(2)); break;
                    case "r:": rosPortStrings.Add(portString.Substring(2)); break;
                    default: throw new InvalidOperationException("\"" + portString + "\" is not a valid port string");
                }
            }

            if (yarpPortStrings.Any()) this.yarpNetwork = new YarpNetwork();
            if (rosPortStrings.Any()) this.rosNetwork = new RosNetwork();

            List<Receiver> receivers = new List<Receiver>();
            foreach (string portString in textPortStrings)
            {
                string name = portString.Split(':').First();
                Port port = name == "-" ? new TextReaderPort() : new TextReaderPort(name);
                receivers.Add(new Receiver(port, timer, portString));
            }
            foreach (string portString in yarpPortStrings)
            {
                string name = portString.Split(':').First();
                Port port = new YarpReaderPort(name, yarpNetwork);
                receivers.Add(new Receiver(port, timer, portString));
            }
            foreach (string portString in rosPortStrings)
            {
                string name = portString.Split(':').First();
                Port port = new RosPort(name, rosNetwork);
                receivers.Add(new Receiver(port, timer, portString));
            }
            this.receivers = receivers;

            if (receivers.Count(receiver => receiver.HasTimer) > 1) throw new ArgumentException("More than one timer stream was found.");

            this.capture = new Capture
            (
                from receiver in receivers
                select new PortData(receiver.PortName, receiver.PortStreams)
            );
        }
开发者ID:SolomonBier,项目名称:streamvis,代码行数:51,代码来源:Session.cs

示例7: Logik

        public Logik()
        {
            Database = new DatabaseAdgang();
            DAQdata = new IndhentDAQData();
            NulpunktObjekt = new Nulpunktsjustering();
            KalibreringObjekt = new Kalibrering();
            FilterObj = new Filter();
            AnalyseKlasse = new Analyse();

            updateUI = new Thread(() => updateListe());

            UILISTE = new List<double>();
            observers = new List<IObserver>();
            FiltreretListe = new List<double>();
            databasetal = new List<double>();
            minKø = new Queue<double>(100);

            beregnetNværdi = 0.0;
            counter = 0;
            kalibreringKoef = KalibreringObjekt.Kalibrer();

            DAQdata.Attach(this);

            for (int i = 0; i < 299; i++)
            {
                UILISTE.Add(0);
            }
        }
开发者ID:banasik,项目名称:Semesterprojekt3,代码行数:28,代码来源:Logik.cs

示例8: FilterByPeriod

        public static List<station> FilterByPeriod(this IEnumerable<station> stats, int? period)
        {
            var now = Helper.CurrentDate;
            var result = new List<station>();

            foreach (var st in stats)
            {
                DateTime? max = st.LastObservDate;

                var period_ = period.GetValueOrDefault(-1);

                bool incl = false;
                if (period_ == 1 && max >= now) incl = true;
                if (period_ == 7 && max >= now.AddDays(-7) && max < now) incl = true;
                if (period_ == 30 && max >= now.AddDays(-30) && max < now.AddDays(-7)) incl = true;
                if (period_ == 60 && max < now.AddDays(-30)) incl = true;

                if (period_ == -1 || incl)
                {
                    //st.LastObservTName = obstname;
                    result.Add(st);
                }
            }
            return result;
        }
开发者ID:jirikadlec2,项目名称:hydrodatacz,代码行数:25,代码来源:MapHelper.cs

示例9: DummyContractsRepository

        internal static IRepository<Contract> DummyContractsRepository()
        {
            var repo = new Mock<IRepository<Contract>>();

            var contracts = new List<Contract>();

            for (int i = 0; i < NumberOfTestObjects; i++)
            {
                contracts.Add(new Contract
                {
                    ClientId = (i % 2 == 0 ? i : 3).ToString(),
                    HitmanId = (i % 2 == 0 ? i : 3).ToString() + "hitman",
                    Deadline = DateTime.Now,
                    Status = ConnectionStatus.Pending,
                    Id = i
                });
            }

            repo.Setup(r => r.GetById(It.Is<int>(x => x == 4))).Returns(() =>
            {
                return contracts.Where(c => c.Id == 4).FirstOrDefault();
            });

            repo.Setup(r => r.All()).Returns(() =>
            {
                return contracts.AsQueryable();
            });

            return repo.Object;
        }
开发者ID:ERIS-Team-TelerikAcademy,项目名称:ERIS-App,代码行数:30,代码来源:DummyRepositories.cs

示例10: ReadExcelData

        private void ReadExcelData(OleDbConnection conn, string sheetName)
        {
            Console.WriteLine("Reading data...");
            var excelDbCommand = new OleDbCommand(@"SELECT * FROM [" + sheetName + "]", conn);
            using (var oleDbDataAdapter = new OleDbDataAdapter(excelDbCommand))
            {
                DataSet ds = new DataSet();
                oleDbDataAdapter.Fill(ds);
                var locations = new List<Location>();
                using (var reader = ds.CreateDataReader())
                {
                    while (reader.Read())
                    {
                        var loc = new Location();
                        loc.Name = reader["City"].ToString();
                        locations.Add(loc);
                    }
                }

                var db = new MagicalCreatureDbContext();
                foreach (var loc in locations)
                {
                    db.Locations.Add(loc);
                }

                db.SaveChanges();
            }
        }
开发者ID:Europium-TA,项目名称:DB-Project,代码行数:28,代码来源:Excel.cs

示例11: btnGenerar_Click

 private void btnGenerar_Click(object sender, EventArgs e)
 {
     if (cmbEdificios.CheckedItems.Count > 0)
     {
         bool todo = true;
         if (cmbEdificios.CheckedItems.Count < cmbEdificios.Items.Count)
         {
             todo = false;
             MessageBox.Show("Solo se generaran las liquidaciones, no el CSV ni informe de emision", "Sistema");
         }
         DateTime periodo = DateTime.Parse("1/" + this.periodo.Value.Month + "/" + this.periodo.Value.Year);
         List<edificio> edificios = new List<edificio>();
         foreach(edificio ed in cmbEdificios.CheckedItems)
         {
             edificios.Add(ed);
         }
         LoadingForm loading = new LoadingForm();
         (new Thread(() => loading.ShowDialog())).Start();
         Business.ControladorInformes.generarAllLiquidaciones(edificios, todo,periodo, vto1.Value, vto2.Value, txtTextoAlPie.Text, Properties.Resources.emergencias, Properties.Resources.qr, Properties.Resources.tijera);
         Invoke(new Action(() => loading.Close()));
         if (MessageBox.Show("Desea abrir la carpeta con los archivos generados?", "Sistema", MessageBoxButtons.YesNo) == DialogResult.Yes)
             //System.Diagnostics.Process.Start(@"Liquidaciones\" + edi.direccion + periodo.Month + "-" + periodo.Year + ".pdf");
             System.Diagnostics.Process.Start("Liquidaciones\\" + periodo.Month + " del " + periodo.Year);
         this.Close();
     }
     else
         MessageBox.Show("Seleccione al menos un edificio", "Sistema");
 }
开发者ID:fedec93,项目名称:Administracion,代码行数:28,代码来源:CrearLiquidaciones.cs

示例12: 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

示例13: Get

        public Publications Get(int id)
        {
            var list = context.Web.Lists.GetByTitle(Title);
            var query = new CamlQuery() { ViewXml = "<View><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Integer'>" + id + "</Value></Eq></Where></Query><RowLimit>1</RowLimit></View>" };
            var items = list.GetItems(query);
            context.Load(items);
            context.ExecuteQuery();

            if (items.Count > 0)
            {
                string[] lines = items[0]["_x0422__x044d__x0433__x0438_"].ToString().Split(',');

                var tags = new List<Tag>();

                foreach (var line in lines)
                {
                    tags.Add(mapTag(line));
                }

                return new Publications()
                {
                    Title = items[0]["Title"].ToString(),
                    Article = items[0]["_x0421__x0442__x0430__x0442__x04"].ToString(),
                    PublicationDate = ((DateTime)items[0]["_x0414__x0430__x0442__x0430__x00"]).AddDays(1),
                    Source = items[0]["_x0418__x0441__x0442__x043e__x04"].ToString(),
                    Subtitle = items[0]["_x041f__x043e__x0434__x0437__x04"].ToString(),
                    Tags = tags
                };
            }
            else
            {
                return null;
            }
        }
开发者ID:ellestragoo,项目名称:new-cft,代码行数:34,代码来源:PublicationsRepository.cs

示例14: 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

示例15: GetUsers

        public IEnumerable<UserResponseModel> GetUsers()
        {
            var users = this.data.Users.All().ToList();
            var listOfUsers = new List<UserResponseModel>();

            foreach (var user in users)
            {
                string userName = user.UserName;

                var ratings = this.data.Ratings.All()
                .Where(r => r.User.UserName == userName)
                .ToList();

                var sumOfAllRatings = 0;
                foreach (var rating in ratings)
                {
                    sumOfAllRatings += rating.Value;
                }

                int ratingsCount = ratings.Count();
                double averageRating = sumOfAllRatings * 1.0 / ratingsCount;

                var newResponseUser = new UserResponseModel()
                {
                    UserName = userName,
                    Rating = ratingsCount == 0 ? 0 : averageRating
                };
                listOfUsers.Add(newResponseUser);
            }

            return listOfUsers;
        }
开发者ID:antonpopov,项目名称:Web-Services-and-Cloud,代码行数:32,代码来源:Users.svc.cs


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