当前位置: 移动技术网 > IT编程>开发语言>c# > C#控制台基础 list<>初始化的两种方法

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

2019年07月18日  | 移动技术网IT编程  | 我要评论

代码一、

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<>初始化的两种方法,希望大家以后多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网