zoukankan      html  css  js  c++  java
  • list<T>集合中的Remove()、RemoveAt()、RemoveRange()、RemoveAll()的用法


    using
    System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { List<string> str = new List<string> { "aa","a1","a2","bb","cc","dd","ee","ff"}; //str.Remove("aa");//指定要删除的内容 //str.RemoveAt(1);//用下表来指定要删除的内容此示例中删除的是bb内容 //str.RemoveRange(0, 2);//删除指定长度的内容此实例会删除aa和bb //str.RemoveAll(a => a.Contains("a"));//使用拉姆达表达式寻找包含a的内容 //然后将包含a的这一类文件全部删除. foreach (string item in str)//遍历显示要显示的内容 { Console.WriteLine(item); } Console.ReadLine(); } } }

    要把这个删除放在最上面因为代码的执行时从上面往下的.

    static void Main(string[] args)
            {
                List<string> str = new List<string> { "aa","a1","a2","bb","cc","dd","ee","ff"};
                List<string> str1 = new List<string>();
                str1.Add("mm");
               
                //添加
                //str.Add("66");//是将内容按照下标添加到最后一个.
                //str.AddRange(str1);//将一个list集合中的内容添加到另一个指定要添加的集合的后面
                str.
    
                foreach (string item in str)//遍历显示要显示的内容
                {
                    Console.WriteLine(item);
                }
    
                Console.ReadLine();
            }

    这个数插入希望可以帮到需要的你们

  • 相关阅读:
    react native配置ip真机测试
    APP Store上架QA&注意事项
    iOS 开发】解决使用 CocoaPods 执行 pod install 时出现
    iphoneX适配!!!
    better-scroll和swiper使用中的坑
    js知识巩固
    vue的学习(常用功能)
    vue学习生命周期(created和mounted区别)
    jq常用功能操作
    移动端中遇到的坑(bug)!!!
  • 原文地址:https://www.cnblogs.com/zsznh/p/10599734.html
Copyright © 2011-2022 走看看