在C#的List集合操作中,移除集合中的元素可以使用Remove方法,不过Remove方法的参数为具体的List集合中的元素,其实还可以使用List集合的RemoveAt方法来移除List集合中的元素,RemoveAt方法的方法签名为void RemoveAt(int index),index代表需要移除的元素在List集合中的索引位置,List集合的索引位置从0开始计算。

例如有个List<int>的集合list1,含有1至10的数字,如果要移除2,则对应索引为1,具体实现语句如下:

List<int> list1 = new List<int>() { , , , , , , , , ,  };
list1.RemoveAt();

最终得到的结果为:list集合中的元素2被移除出去了。

备注:原文转载自博主个人站IT技术小趣屋,原文链接C#中List集合使用RemoveAt方法移除指定索引位置的元素_IT技术小趣屋

博主个人技术交流群:960640092,博主微信公众号如下:

最新文章

  1. Leetcode Distinct Subsequences
  2. C语言中的结构体,结构体数组
  3. exceptions-in-java
  4. GLSL Notes
  5. ZOJ Light Bulb - 3203
  6. Jquery easyui treegrid实现树形表格的行拖拽
  7. 关于升级linux下apache
  8. myEclipse和eclipse修改或复制项目名称后-更新部署名称
  9. Linux C++服务器程序设计范式
  10. Android之路-------传说中的大喇叭(广播接收器)
  11. Tomcat v7.0 Server at localhost are already in use,tomcat提示端口被占用,tomcat端口已经被使用,tomcat端口占用
  12. django xadmin 1不在可用的选项中
  13. C++解析二
  14. 如何使用putty远程连接linux
  15. Android Jsoup 爬取网页数据
  16. 【bzoj】2733: [HNOI2012]永无乡
  17. 基于asp.net mvc的近乎产品开发培训课程(第三讲)
  18. jQuery ajax 当async为false时解决同步操作失败的问题
  19. istringstream和ostringstream的实现
  20. HDU 4946 凸包

热门文章

  1. YoTube 视频如何下载
  2. ArgumentException: The Assembly Mono.WebBrowser is referenced by System.Windows.Forms (&#39;Assets/Plugins/System.Windows.Forms.dll&#39;). But the dll is not allowed to be included or could not be found.
  3. DELPHI无类型参数
  4. mysql实现oracle存储过程默认参数
  5. npm install Error: EACCES: permission denied, mkdir
  6. Qt QtXml读取xml文件内容
  7. java.io.IOException: Input is binary and unsupported
  8. springboot 整合rabbitMQ
  9. [LeetCode] 110. Balanced Binary Tree 平衡二叉树
  10. Jenkins - 安装并启动Jenkins