using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _07List泛型集合
{
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>();//定义一个int集合
list.Add(5);//添加一个元素5
list.AddRange(new int[] { 1,4,3,7});
// list.Remove(3);
//list.RemoveAll(n=>n>4);
// list.RemoveAt(3);
// list.RemoveRange(1, 3);
// list.Insert(0, 34);
// list.InsertRange(1,new int[] { 200,300,400});
//集合转数组调用ToArray()
int[] nums=list.ToArray();
List<string> list2 = new List<string>();
string[] str= list2.ToArray();
string[] str3 = {"hello","world"};
List<string>list3= str3.ToList();
//遍历输出list
for (int i = 0; i < list.Count;
C#之四 List 泛型集合
最新推荐文章于 2025-05-20 20:41:31 发布