欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#控制台基础 list<>初始化的两种方法

程序员文章站 2023-12-31 21:46:58
代码一、 using system; using system.collections.generic; using system.linq; using...

代码一、

using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;

namespace consoleapplication1
{
  class program
  {
    static void main(string[] args)
    {
      list<int> list1 = new list<int> { 1, 2, 3, 4, 5, };
    }
  }
}

代码二、

using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;

namespace consoleapplication1
{
  class program
  {
    static void main(string[] args)
    {
      list<int> list1 = new list<int>();
      list1.add(1);
      list1.add(2);
      list1.add(3);
      list1.add(4);
      list1.add(5);
    }
  }
}

以上就是list<>初始化的两种方法,希望大家以后多多支持。

上一篇:

下一篇: