首先,声明一个列表,例如:
  Listteams=newList();
  要将项目添加到C#列表,请使用Add()办法
  teams.Add("US");
  teams.Add("Canada");
  teams.Add("India");
  teams.Add("Australia");
  可以测验运行以下代码以将项目添加到C#中的列表中
  usingSystem;
  usingSystem.Collections.Generic;
  publicclassDemo
  {
  publicstaticvoidMain(string[]args)
  {
  varteams=newList();
  teams.Add("US");
  teams.Add("Canada");
  teams.Add("India");
  teams.Add("Australia");
  Console.WriteLine("Elements...");
  foreach(varcountrieinteams)
  Console.WriteLine(countrie);
  }
  }
  运行后,程序会将一切项目打印出来。小伙伴,你有没有做对呢

相关文章:

  • 2021-05-19
  • 2021-04-05
  • 2021-10-13
  • 2021-11-30
  • 2022-02-19
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2022-01-16
  • 2022-12-23
  • 2022-01-08
  • 2021-06-10
  • 2022-12-23
相关资源
相似解决方案