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


C# List.Insert方法代码示例

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


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

示例1: FinishedLoadCategory

        public void FinishedLoadCategory(List<Category> list)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DeCallbackCategoryList(FinishedLoadCategory), list);
                return;
            }

            //adding All to search in all category
            Category all = new Category();
            all.id = 0;
            all.name = "All";
            list.Insert(0, all);

            //adding a favorite category, this is kind of special category.
            Category fav = new Category();
            fav.id = -1;
            fav.name = "Favorites";
            list.Insert(1, fav);

            comboBoxCategory.Items.Clear();
            categories.Clear();
            foreach (Category i in list)
            {
                categories.Add(i);
                comboBoxCategory.Items.Add(i.name);
            }
            comboBoxCategory.SelectedIndex = 0;
            is_get_category = true;
            EnableSearch();
        }
开发者ID:nghoang,项目名称:settv,代码行数:31,代码来源:MainApp.cs

示例2: Main

        static void Main(string[] args)
        {
            Console.Title = "管理学生信息";

            List<Student> students = new List<Student>();              //学生信息列表
            students.Add(new Student("张三", 20, "男", 20120001));     //添加学生"张三"的信息
            students.Add(new Student("李四", 19, "女", 20120002));     //添加学生"李四"的信息
            students.Add(new Student("王五", 18, "男", 20120003));     //添加学生"王五"的信息
            students.Add(new Student("赵六", 21, "女", 20120004));     //添加学生"赵六"的信息
            Console.WriteLine("遍历学生信息表,输出学生信息:");
            foreach (Student s in students)
            {
            Console.WriteLine("{0}\t{1}岁\t{2}生\t{3}号", s.Name, s.Age, s.Sex, s.ID);
            }

            Console.WriteLine("删除学生“李四”的信息!");
            students.RemoveAt(1);
            Console.WriteLine("在表头插入学生“孙七”的信息!");
            students.Insert(0, new Student("孙七", 22, "男", 20120005));
            Console.WriteLine("在表尾插入学生“周八”信息!");
            students.Insert(4, new Student("周八", 17, "女", 20120006));
            Console.WriteLine("重新遍历学生信息表,输出学生信息:");
            foreach (Student s in students)
            {
            Console.WriteLine("{0}\t{1}岁\t{2}生\t{3}号", s.Name, s.Age, s.Sex, s.ID);
            }

            Console.ReadLine();
        }
开发者ID:dalinhuang,项目名称:wdeqawes-efrwserd-rgtedrtf,代码行数:29,代码来源:Program.cs

示例3: Initialize

 public override void Initialize(ContentManager content, WaveManager manager)
 {
     infiniteAmmoModeOn = true;
     infiniteFoodModeOn = true;
     isTutorialWave = true;
     waveSize = wavesize;
     spawnTimings = new List<double>(waveSize);
     enemiesToSpawn = new List<Enemy>(waveSize);
     lootList = new List<Loot>(waveSize);
     enemiesToSpawn.Insert(0, new Enemy1());
     spawnTimings.Insert(0, baseTime + 0 * interval);
     enemiesToSpawn.Insert(1, new Enemy1());
     spawnTimings.Insert(1, 2 * interval);
     enemiesToSpawn.Insert(2, new Enemy1());
     spawnTimings.Insert(2, 3.5 * interval);
     enemiesToSpawn.Insert(3, new Enemy1());
     spawnTimings.Insert(3, 5 * interval);
     enemiesToSpawn.Insert(waveSize - 1, new HeadShotTest());
     spawnTimings.Insert(waveSize - 1, baseTime + 6.5 * interval);
     lootList.Add(new SniperAmmoLoot(2, content));
     lootList.Add(new SniperAmmoLoot(2, content));
     //lootList.Add(new FoodLoot(1, content));
     lootList.Add(new MachineGunAmmoLoot(5, content));
     lootList.Add(new SniperAmmoLoot(2, content));
     lootList.Add(new MachineGunAmmoLoot(5, content));
     openingTextFilename = "Content//Text//TutorialWave1Open.txt";
     layout = new FoxholeLayout();
     helpTexture = content.Load<Texture2D>("Graphics\\Tutorial1Help");
     helpTextureController = content.Load<Texture2D>("Graphics\\Tutorial1HelpController");
     base.Initialize(content, manager);
 }
开发者ID:pel5xq,项目名称:InFoxholesGame,代码行数:31,代码来源:TutorialWave1.cs

示例4: SortByAfter

        private IList<IMenuModel> SortByAfter(IList<IMenuModel> menuModels)
        {
            var sorted = new List<IMenuModel>(menuModels);

            foreach (IMenuModel model in menuModels)
            {
                int newIndex =
                    sorted.FindIndex(m => m.Name.Equals(model.After, StringComparison.InvariantCultureIgnoreCase));

                if (newIndex < 0) continue;

                int currentIndex = sorted.IndexOf(model);

                if (currentIndex < newIndex)
                {
                    sorted.Remove(model);
                    sorted.Insert(newIndex, model);
                }
                else
                {
                    sorted.Remove(model);
                    sorted.Insert(newIndex + 1, model);
                }
            }

            return sorted;
        }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:27,代码来源:CollectionMenuModel.cs

示例5: Main

    static void Main()
    {
        // Create a List called Deck
        List<int> Deck = new List<int>();

        for (int iCards = 0; iCards < 52; iCards++)
        {
            Deck.Insert(0, iCards + 1); //PUSH
        }

        //Shuffle Deck
        // Declare an Instance of Random Class outside the Loop

        Random MyRandNumb = new Random() ;
           int iSwap = 0;

        foreach (int card in Deck )
        {
        // Generate Random number from 1 to CardNum - 1
        int RandomCard = MyRandNumb.Next(1, 52) ;
            iSwap = Deck[RandomCard];
            Deck.RemoveAt(RandomCard);
        Deck.Insert(0, iSwap);
        }

        Console.WriteLine("Count: {0}", Deck.Count);

        // Print them to the screen
        foreach (int card in Deck )
        {
            Console.WriteLine(card);
        }
    }
开发者ID:JeremiahZhang,项目名称:AKA,代码行数:33,代码来源:Shuffle1.cs

示例6: GetComments

        public static string[] GetComments(IToken[] FileTokens, List<IToken> alreadyTakenComments, int lastTokenLineNo,
            int prevTokenIndex, int nextTokenIndex, bool acn = false)
        {
            List<string> comments = new List<string>();
            int WS = acn ? acnLexer.WS : asn1Lexer.WS;
            int COMMENT = acn ? acnLexer.COMMENT : asn1Lexer.COMMENT;
            int COMMENT2 = acn ? acnLexer.COMMENT2 : asn1Lexer.COMMENT2;

            //first see if there comments on the same line

            while (nextTokenIndex >= 0 && nextTokenIndex < FileTokens.Length)
            {
                IToken t = FileTokens[nextTokenIndex++];
                if (alreadyTakenComments.Contains(t))
                {
                    break;
                }
                if (t.Line != lastTokenLineNo)
                {
                    break;
                }
                if (t.Type == WS)
                {
                    continue;
                }
                else if (t.Type == COMMENT || t.Type == COMMENT2)
                {
                        comments.Insert(0, t.Text);
                        alreadyTakenComments.Add(t);
                }
                else
                {
                    break;
                }

            }

            //if no comments were found at the same line, then look back (above)
            if (comments.Count == 0)
            {

                while (prevTokenIndex >= 0 && prevTokenIndex < FileTokens.Length)
                {
                    IToken t = FileTokens[prevTokenIndex--];
                    if (alreadyTakenComments.Contains(t))
                        break;
                    if (t.Type == WS)
                        continue;
                    else if (t.Type == COMMENT || t.Type == COMMENT2)
                    {
                            comments.Insert(0, t.Text);
                            alreadyTakenComments.Add(t);
                    }
                    else
                        break;
                }
            }

            return comments.ToArray();
        }
开发者ID:Kampbell,项目名称:asn1scc,代码行数:60,代码来源:Comments.cs

示例7: FromBase10

        public static string FromBase10(int number, int targetBase)
        {
            if (targetBase < 2 || targetBase > 36) return "";
            if (targetBase == 10) return number.ToString();

            int n = targetBase;
            int q = number;
            int r;
            List<string> rtn = new List<string>();

            while (q >= n)
            {

                r = q % n;
                q = q / n;

                if (r < 10)
                    rtn.Insert(0, r.ToString());
                else
                    rtn.Insert(0, Convert.ToChar(r + 55).ToString());
            }

            if (q < 10)
                rtn.Insert(0, q.ToString());
            else
                rtn.Insert(0, Convert.ToChar(q + 55).ToString());

            return string.Join("", rtn);
        }
开发者ID:krstan4o,项目名称:TelerikAkademy,代码行数:29,代码来源:Extensions.cs

示例8: Check

 static List<int> Check(List<int> num, int digit, List<int> paths)
 {
     int i=0;
     // - FOR EACH PATH OF DIGIT, CHECK LOCATION IN FINAL NUMBER
     for (i=0;i<paths.Count;i++)
     {
     int path = paths[i];
     // - IF PATH DIGIT IS NOT IN FINAL, ADD AT POS 0
     if (num.IndexOf(path) == -1)
     {
         num.Insert(0,path);
     }
     // - IF DIGIT IS NOT IN FINAL, ADD BEFORE PATH DIGIT
     if (num.IndexOf(digit) == -1)
     {
         num.Insert(num.IndexOf(path),digit);
     }
     // - IF DIGIT COMES AFTER PATH DIGIT, REMOVE DIGIT AND PUT IT BEFORE PATH
     else if (num.IndexOf(digit) > num.IndexOf(path))
     {
         num.RemoveAt(num.IndexOf(digit));
         num.Insert(num.IndexOf(path),digit);
     }
     // - OTHERWISE NUMBER CHECKS OUT
     else if (num.IndexOf(digit) < num.IndexOf(path))
     {
         continue;
     }
     }
     return num;
 }
开发者ID:xylotism,项目名称:xylotism-project-euler,代码行数:31,代码来源:project-euler-079.cs

示例9: GetBSAList

 private static string GetBSAList(bool p_booInsertAI)
 {
   var bsas =
     new List<string>(
       NativeMethods.GetPrivateProfileString("Archive", "SArchiveList", null,
                                             ((FalloutNewVegasGameMode.SettingsFilesSet)
                                               Program.GameMode.SettingsFiles).FOIniPath).Split(new[]
                                               {
                                                 ','
                                               }, StringSplitOptions.RemoveEmptyEntries));
   var lstNewBSAs = new List<string>();
   for (var i = 0; i < bsas.Count; i++)
   {
     bsas[i] = bsas[i].Trim(' ');
     if (bsas[i] == OldAiBsa)
     {
       continue;
     }
     if (bsas[i].Contains("Misc"))
     {
       lstNewBSAs.Insert(0, bsas[i]);
     }
     else if (bsas[i] != AiBsa)
     {
       lstNewBSAs.Add(bsas[i]);
     }
   }
   if (p_booInsertAI)
   {
     lstNewBSAs.Insert(0, AiBsa);
   }
   return string.Join(", ", lstNewBSAs.ToArray());
 }
开发者ID:IntegralLee,项目名称:fomm,代码行数:33,代码来源:ArchiveInvalidation.cs

示例10: RunTest

        public static bool RunTest( string inputRom, string testFile,  string cmdLineArgs)
        {
            bool ret = false;
            String[] args = cmdLineArgs.Split(new char[] { ' ' });
            List<String> listArgs = new List<String>(args);
            listArgs.Insert(0, inputRom);
            listArgs.Insert(1, testFile);
            args = listArgs.ToArray();

            MainClass.RunMain(args);
            String testFileContents = File.ReadAllText(testFile);
            if (String.Compare(testFileContents, MainClass.TestString) != 0)
            {
                //fail
                File.WriteAllText("output.txt", testFileContents);
                String argLine = String.Concat(testFile, " output.txt");
                Process.Start(diffTool, argLine);
            }
            else
            {
                ret = true;
            }

            return ret;
        }
开发者ID:tecmopsycho,项目名称:tsbtools,代码行数:25,代码来源:TestClass.cs

示例11: CreateLSList

        private static List<bool> CreateLSList(List<int> S)
        {
            // L/S list where S is true and L is false
            List<bool> t = new List<bool>();

            for (int i = S.Count - 1; i >= 0; i--)
            {
                if (i == S.Count - 1)
                {
                    t.Insert(0, true); //insert S for last charachter
                }
                else
                {
                    if (S[i] > S[i + 1])
                    {
                        t.Insert(0, false); //insert L for S[i] > S[i + 1]
                    }
                    else if (S[i] < S[i + 1])
                    {
                        t.Insert(0, true); //insert S for S[i] < S[i + 1]
                    }
                    else
                    {
                        t.Insert(0, t[0]); //copy value if S[i] == S[i + 1]
                    }
                }
            }

            return t;
        }
开发者ID:melitafertalj,项目名称:Bioinformatika2016,代码行数:30,代码来源:Program.cs

示例12: GetVariations

        public static void GetVariations(List<int> toSearch, int Left, int LengthToBuild)
        {
            // If This is the last element in the squence
            // get all possible variations and return
            if (LengthToBuild==1)
            {
                // Step 1: Print Variations
                for (int position = Left; position < toSearch.Count; position++)
                {
                    // Step 1: Print Current
                    PrintCurrentVariation(toSearch, Left);

                    // Step 2: Shuffle
                    toSearch.Insert(Left, toSearch[toSearch.Count - 1]);
                    toSearch.RemoveAt(toSearch.Count - 1);
                }
                // Step 2: Go back up
                return;
            }

            // OtherWise pick the next element in the sequence
            // and Send down
            for (int currElement = 0; currElement < toSearch.Count; currElement++)
            {
                // Step 1: Get Variatopms
                GetVariations(toSearch, Left + 1, LengthToBuild-1);

                // Step 2: Shuffle
                // last element goes first
                toSearch.Insert(Left, toSearch[toSearch.Count - 1]);
                toSearch.RemoveAt(toSearch.Count - 1);
            }

            return;
        }
开发者ID:tvmarinov,项目名称:Homework,代码行数:35,代码来源:CombinationsOfSet.cs

示例13: Load_Load

 private void Load_Load(object sender, EventArgs e)
 {
     newWidth.Text = ApplicationSettings.LastMapSize.Width.ToString();
     newHeight.Text = ApplicationSettings.LastMapSize.Height.ToString();
     if (multiBoard.Boards.Count == 0)
     {
         newTab.Checked = true;
         newTab.Enabled = false;
     }
     else
         newTab.Checked = ApplicationSettings.newTab;
     List<string> listBoxObjects = new List<string>();
     foreach (DictionaryEntry map in Program.InfoManager.Maps)
         listBoxObjects.Add((string)map.Key + " - " + (string)map.Value);
     listBoxObjects.Sort();
     listBoxObjects.Insert(0, "CashShopPreview");
     listBoxObjects.Insert(0, "MapLogin");
     listBoxObjects.Insert(0, "MapLogin1");
     foreach (string map in listBoxObjects)
         mapNamesBox.Items.Add(map);
     switch (ApplicationSettings.lastRadioIndex)
     {
         case 0:
             NewSelect.Checked = true;
             break;
         case 1:
             XMLSelect.Checked = true;
             break;
         case 2:
             WZSelect.Checked = true;
             break;
     }
 }
开发者ID:hanistory,项目名称:hasuite,代码行数:33,代码来源:Load.cs

示例14: GetSensorList

 public static ICollection<string> GetSensorList()
 {
     var sensors = new List<string>(WebSocketEventProcessor.g_devices.Keys);
     sensors.Insert(0, "All");
     sensors.Insert(0, "None");
     return sensors;
 }
开发者ID:carloserodriguez2000,项目名称:connectthedots,代码行数:7,代码来源:SensorInventory.cs

示例15: GetTaxDisplayTypesList

        protected List<SelectListItem> GetTaxDisplayTypesList(CustomerRoleModel model)
        {
            var list = new List<SelectListItem>();

            if (model.TaxDisplayType.HasValue)
            {
                list.Insert(0, new SelectListItem()
                {
                    Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.IncludingTax"),
                    Value = "0",
                    Selected = (TaxDisplayType)model.TaxDisplayType == TaxDisplayType.IncludingTax
                });
                list.Insert(1, new SelectListItem()
                {
                    Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.ExcludingTax"),
                    Value = "10",
                    Selected = (TaxDisplayType)model.TaxDisplayType == TaxDisplayType.ExcludingTax
                });
            }
            else
            {
                list.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.IncludingTax"), Value = "0" });
                list.Insert(1, new SelectListItem() { Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.ExcludingTax"), Value = "10" });
            }

            return list;
        }
开发者ID:GloriousOnion,项目名称:SmartStoreNET,代码行数:27,代码来源:CustomerRoleController.cs


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