首页 > 其他分享 >List 泛型集合

List 泛型集合

时间:2023-03-21 16:13:07浏览次数:47  
标签:int List list 集合 Add 泛型

 

复制代码
using System;
using System.Collections.Generic;

namespace List_泛型集合
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建泛型集合对象
            List<int> list = new List<int>();//int数据类型

            //添加单个元素
            list.Add(1);
            list.Add(2);
            list.Add(3);

            //添加集合
            list.AddRange(new int[] {1,2,3,4,5 });

            //List泛型集合可以转换为数组
            int[] nums = list.ToArray();
        }
    }
}
复制代码

 

  分类: C# 标签: C# 好文要顶 关注我 收藏该文   小春博客
粉丝 - 0 关注 - 0     +加关注 0 0       « 上一篇: Hashtable 键值对集合
» 下一篇: 多态之虚方法 posted @ 2022-11-20 21:36  小春博客  阅读(5)  评论(0)  编辑  收藏  举报    

标签:int,List,list,集合,Add,泛型
From: https://www.cnblogs.com/chungeblog/p/17240355.html

相关文章