【转载】C#中List集合使用RemoveAt方法移除指定索引位置的元素
2024-10-20 00:30:55
在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,博主微信公众号如下:
最新文章
- Leetcode Distinct Subsequences
- C语言中的结构体,结构体数组
- exceptions-in-java
- GLSL Notes
- ZOJ Light Bulb - 3203
- Jquery easyui treegrid实现树形表格的行拖拽
- 关于升级linux下apache
- myEclipse和eclipse修改或复制项目名称后-更新部署名称
- Linux C++服务器程序设计范式
- Android之路-------传说中的大喇叭(广播接收器)
- Tomcat v7.0 Server at localhost are already in use,tomcat提示端口被占用,tomcat端口已经被使用,tomcat端口占用
- django xadmin 1不在可用的选项中
- C++解析二
- 如何使用putty远程连接linux
- Android Jsoup 爬取网页数据
- 【bzoj】2733: [HNOI2012]永无乡
- 基于asp.net mvc的近乎产品开发培训课程(第三讲)
- jQuery ajax 当async为false时解决同步操作失败的问题
- istringstream和ostringstream的实现
- HDU 4946 凸包
热门文章
- YoTube 视频如何下载
- 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.
- DELPHI无类型参数
- mysql实现oracle存储过程默认参数
- npm install Error: EACCES: permission denied, mkdir
- Qt QtXml读取xml文件内容
- java.io.IOException: Input is binary and unsupported
- springboot 整合rabbitMQ
- [LeetCode] 110. Balanced Binary Tree 平衡二叉树
- Jenkins - 安装并启动Jenkins