集合与数组比较:
(1)长度可以改变
(2)添加数据时,不必考虑具体类型
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace GenericTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- List list = new List();
- list.Add(1);
- list.Add(2);
- list.Add(3);
- list.AddRange(new int[]{4,5,6,7,8});
- list.AddRange(list);//将自身作为参数添加到列表
- Console.WriteLine("======输出=======");
- for(int i=0;i
- Console.WriteLine(list[i]);
- Console.WriteLine("======反转=======");
- list.Reverse();
- for (int i = 0; i
关注打赏
立即登录/注册


微信扫码登录