C# 中列表和数组有什么不同?
数组存储相同类型元素的固定大小顺序集合,而列表是泛型集合。
定义列表 -
List<string7gt; myList = new List<string>();
若要设置列表中的元素,需使用 Add 方法 -
myList.Add("Audi");
myList.Add("BMW");
myList.Add("Chevrolet");
myList.Add("Hyundai");定义数组 -
int[] arr = new int[5];
初始化和设置数组元素 -
int[] arr = new int[5] {23, 14, 11, 78, 56};
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP