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


C# List.Add方法代码示例

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


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

示例1: GetTestBooks

 public static List<Book> GetTestBooks()
 {
     List<Book> temp = new List<Book>();
     temp.Add(new Book(1, "Sota ja rauha", "Leo Tolstoi", "Venäjä", 1867));
     temp.Add(new Book(2, "Anna Karenina", "Leo Tolstoi", "Venäjä", 1877));
     return temp;
 }
开发者ID:Crowmoore,项目名称:IIO11300,代码行数:7,代码来源:Book.cs

示例2: Install

        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);

            var installdir = GetParameter("targetdir");

            string msg = "";
            foreach (var k in Context.Parameters.Keys)
                msg += (k + "\n");
            msg += "VALUES:\n";
            foreach (var v in Context.Parameters.Values)
                msg += (v + "\n");
            //MessageBox.Show(msg);

            List<string> writeableDirs = new List<string>();

            string configDir = Path.Combine(Path.Combine(installdir, "Myro"), "config");
            string storeDir = Path.Combine(Path.Combine(installdir, "Myro"), "store");

            writeableDirs.Add(configDir);
            writeableDirs.Add(storeDir);
            writeableDirs.AddRange(Directory.GetDirectories(configDir, "*", SearchOption.AllDirectories));
            writeableDirs.AddRange(Directory.GetDirectories(storeDir, "*", SearchOption.AllDirectories));

            string dirs = "";
            foreach (var d in writeableDirs)
            {
                dirs += (d + "\n");
                if (GrantModifyAccessToFolder("Everyone", d) != true)
                    throw new Exception("Couldn't make " + d + " writeable");
            }

            //MessageBox.Show("Made writeable:\n" + dirs);
        }
开发者ID:roboshepherd,项目名称:myro-epuck,代码行数:34,代码来源:Installer1.cs

示例3: AddBytes

        public static void AddBytes(List<byte> list, int value)
        {
            byte b0 = (byte)value;
            byte b1 = (byte)(value >> 8);

            list.Add(b0);
            list.Add(b1);
        }
开发者ID:neuroradiology,项目名称:Sxz,代码行数:8,代码来源:Writer.cs

示例4: AddBytes32

        public static void AddBytes32(List<byte> list, int value)
        {
            byte[] byteArray = BitConverter.GetBytes(value);

            list.Add(byteArray[0]);
            list.Add(byteArray[1]);
            list.Add(byteArray[2]);
            list.Add(byteArray[3]);
        }
开发者ID:neuroradiology,项目名称:Sxz,代码行数:9,代码来源:Writer.cs

示例5: ProfileWindow

        public ProfileWindow(ProfileItem profileItem, OutoposManager outoposManager, BufferManager bufferManager)
        {
            _profileItem = profileItem;
            _outoposManager = outoposManager;
            _bufferManager = bufferManager;

            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            _wikiTextBox.MaxLength = Wiki.MaxNameLength;
            _chatTextBox.MaxLength = Chat.MaxNameLength;

            lock (_profileItem.ThisLock)
            {
                _uploadSignature = _profileItem.UploadSignature;
                _signatureCollection.AddRange(_profileItem.TrustSignatures);
                _wikiCollection.AddRange(_profileItem.Wikis);
                _chatCollection.AddRange(_profileItem.Chats);
            }

            _signatureListView.ItemsSource = _signatureCollection;
            _wikiListView.ItemsSource = _wikiCollection;
            _chatListView.ItemsSource = _chatCollection;

            _signatureComboBox.ItemsSource = digitalSignatureCollection;

            this.Sort();
        }
开发者ID:networkelements,项目名称:Outopos,代码行数:31,代码来源:ProfileWindow.xaml.cs

示例6: ConvertBoolsToBytes

        public static List<byte> ConvertBoolsToBytes(bool[] data)
        {
            List<byte> result = new List<byte>();
            //wrap into 8 bit bunches of a byte

            byte eightBits = 0;
            int counter = 0;
            foreach (bool b in data)
            {
                //write to next location on eightBits

                if (b)
                {
                    eightBits |= Writer.Masks[counter];
                }

                counter++;

                if (counter > 7)
                {
                    counter = 0;
                    result.Add(eightBits);
                    eightBits = 0;
                }
            }

            if (counter > 0)
            {
                //pad out the eightBits with zeros then add
                result.Add(eightBits);
            }

            return result;
        }
开发者ID:jubalh,项目名称:Sxz,代码行数:34,代码来源:BitPlane.cs

示例7: btnBrowse_Click

 private void btnBrowse_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         btnUpload.Enabled = true;
         lblError.Text = "";
         #region dataGridView stuff
         List<String> files = openFileDialog1.SafeFileNames.ToList();
         List<Library.File> myFiles = new List<Library.File>();
         foreach (string f in files)
         {
             Library.File file = new Library.File(f, "", Project);
             myFiles.Add(file);
         }
         dataGridView1.DataSource = myFiles;
         dataGridView1.Columns.Remove("id");
         dataGridView1.Columns.Remove("VersionNr");
         dataGridView1.Columns.Remove("FileLock");
         dataGridView1.Columns.Remove("FileLockTime");
         dataGridView1.Columns.Remove("Project");
         dataGridView1.AutoResizeColumns();
         #endregion
         foreach (string filepath in openFileDialog1.FileNames)
         {
             fullFilePathList.Add(filepath);
             fileToUploadList.Add(Path.GetFileName(filepath));
         }
     }
 }
开发者ID:dmab0914-Gruppe-2,项目名称:3-Semester-Project-Share,代码行数:29,代码来源:MultiUpload.cs

示例8: GetPortInfo

        public List<PortInfo> GetPortInfo()
        {
            List<PortInfo> portInfo = new List<PortInfo>();

            string ip = Convert.ToString(Net.GetExternalIpAddress(30000));
            foreach (INetFwOpenPort port in GetAuthOpenPortsList())
            {
                portInfo.Add(new PortInfo()
                {
                    IP = ip,
                    Port = port.Port,
                    Name = port.Name
                });
                //sb.AppendLine(ip + ":" + port.Port + " - " + port.Name + " - " + port.Enabled + " - " + port.IpVersion);
                Console.WriteLine(port.Port + ", " + port.Name);
            }
            /*StringBuilder sb = new StringBuilder();
            foreach (INetFwOpenPort port in GetAuthOpenPortsList())
            {
                
                sb.AppendLine(ip + ":" + port.Port + " - " + port.Name + " - " + port.Enabled + " - " + port.IpVersion);
                Console.WriteLine(port.Port + ", " + port.Name);
            }
            System.Windows.Forms.MessageBox.Show(sb.ToString());*/
            return portInfo;
        }
开发者ID:rasadeyan,项目名称:RestlessHoneySeeker,代码行数:26,代码来源:FirewallManager.cs

示例9: Setup

        public Setup()
        {
            LoadPlugins();
            AllTitlesProcessed = false;
            CurrentTitle = null;
            CurrentTitleIndex = 0;
            current = this;
            //_titleCollection.loadTitleCollection();
            _ImporterSelection = new Choice();
            List<string> _Importers = new List<string>();
            foreach (OMLPlugin _plugin in availablePlugins) {
                OMLApplication.DebugLine("[Setup] Adding " + _plugin.Name + " to the list of Importers");
                _Importers.Add(_plugin.Description);
            }

            _ImporterSelection.Options = _Importers;
            _ImporterSelection.ChosenChanged += delegate(object sender, EventArgs e)
            {
                OMLApplication.ExecuteSafe(delegate
                {
                    Choice c = (Choice)sender;
                    ImporterDescription = @"Notice: " + GetPlugin().SetupDescription();
                    OMLApplication.DebugLine("Item Chosed: " + c.Options[c.ChosenIndex]);
                });
            };
        }
开发者ID:peeboo,项目名称:open-media-library,代码行数:26,代码来源:Setup.cs

示例10: ReadLine

        public override string ReadLine()
        {
            if (stream.Position == stream.Length)
            {
                return null;
            }

            var byteList = new List<int>();
            while (stream.Position != stream.Length)
            {
                int b = stream.ReadByte();
                if (b == (int)'\n')
                {
                    break;
                }
                else
                {
                    byteList.Add(b);
                }
            }
            while (byteList[byteList.Count - 1] == (int)'\r')
            {
                byteList.RemoveAt(byteList.Count - 1);
            }
            return Encoding.UTF8.GetString(byteList.Select(value => (byte)value).ToArray());
        }
开发者ID:KalitaAlexey,项目名称:axxon_soft_test_task,代码行数:26,代码来源:UnbufferedStreamReader.cs

示例11: buttonReLoan_Click

        private void buttonReLoan_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List<int> books = new List<int>();

            foreach (DataGridViewRow row in dataGridViewLoaned.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {

                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.DateLoaned = DateTime.Now;
                        cBook.DateReturned = DateTime.Now.AddMonths(1);
                        MessageBox.Show("Презаписването е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
开发者ID:nikup,项目名称:Library-IT-Olympiad,代码行数:34,代码来源:FormReturn.cs

示例12: buttonReserve_Click

        private void buttonReserve_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List<int> books = new List<int>();

            foreach (DataGridViewRow row in dataGridViewBooks.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {

                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.Reservation = true;
                        MessageBox.Show("Резервирането е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
开发者ID:nikup,项目名称:Library-IT-Olympiad,代码行数:33,代码来源:FormSearch.cs

示例13: GetBrotherNodes

        /// <summary>兄弟ノードを取得する。
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static TreeNode[] GetBrotherNodes(this TreeNode node)
        {
            var broNodes = new List<TreeNode>();

            for (var iNode = node.PrevNode; iNode != null; iNode = iNode.PrevNode)
            {
                broNodes.Add(iNode);
            }

            broNodes.Reverse();

            for (var iNode = node.NextNode; iNode != null; iNode = iNode.NextNode)
            {
                broNodes.Add(iNode);
            }

            return broNodes.ToArray();
        }
开发者ID:robot-punk,项目名称:csharp_programs,代码行数:22,代码来源:TreeViewUtility.cs

示例14: GetProcesses

 public static List<ProcessInfo> GetProcesses()
 {
     //var result = new StringBuilder();
     var result = new List<ProcessInfo>();
     var processList = Process.GetProcesses();
     foreach (Process p in processList)
     {
         result.Add(new ProcessInfo() { Name = p.ProcessName, PID = p.Id });
         //result.AppendLine("Name: " + p.ProcessName + ", PID: " + p.Id);// + ", Start Time: " + p.StartTime + ", CPU Time: " + p.TotalProcessorTime + ", Threads: " + p.Threads);
     }
     //return result.ToString();
     return result;
 }
开发者ID:rasadeyan,项目名称:RestlessHoneySeeker,代码行数:13,代码来源:OS.cs

示例15: GetBooksByTitle

        public List<Book> GetBooksByTitle(string title)
        {
            List<Book> result = new List<Book>();
            foreach (Book book in Books)
            {
                if (book.Title == title)
                {
                    result.Add(book);
                }
            }

            return result;
        }
开发者ID:mitev-web,项目名称:acad-asp-mvc,代码行数:13,代码来源:Library.cs


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