WPF中List的Add()与Insert()方法的区别
2016-03-15 15:37
423 查看
先来看看定义:
View Code
public void Insert(int index, T item); 该方法接受两个参数,第一个为下标,第二个为要添加的元素
需求: 要求往List中添加数据,而且后面加的数据始终要排在第一的位置,
添加 5 6 7 8 9,通过Insert(0, number), 这里的0就代表第一个位置,那么结果为{9, 8, 7, 6, 5}
// // Summary: // Inserts an element into the System.Collections.Generic.List<T> at the specified // index. // // Parameters: // index: // The zero-based index at which item should be inserted. // // item: // The object to insert. The value can be null for reference types. // // Exceptions: // System.ArgumentOutOfRangeException: // index is less than 0.-or-index is greater than System.Collections.Generic.List<T>.Count.
View Code
public void Insert(int index, T item); 该方法接受两个参数,第一个为下标,第二个为要添加的元素
需求: 要求往List中添加数据,而且后面加的数据始终要排在第一的位置,
添加 5 6 7 8 9,通过Insert(0, number), 这里的0就代表第一个位置,那么结果为{9, 8, 7, 6, 5}
相关文章推荐
- 二维数据按某个字段排列顺序
- FPGA、ARM、单片机下载方式及原理的比较
- LINUX内核之内存屏障
- iOS开发-文件管理
- Linux case语句
- linux 命名信号量实现进程间的互斥与同步
- linux系统关机与重新启动命令
- 《与小卡特一起学Python》 Code5 for循环
- wpf计时器
- 冒泡排序
- 动静分离—Nginx+Tomcat
- 如何对读写的网格部件字段进行只读控制
- 单链表和双向链表java实现
- CUDA与PyCUDA开发环境配置详情
- Java量与变量的区别
- 网络编程
- Android-PullToRefresh下拉刷新库基本用法
- $.ajax()方法详解
- css外边距合并和z-index的问题
- iOS-网络请求(传字符串数组参数)