1、List泛型集合

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace _02_List泛型集合
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             //创建泛型集合对象
14             //List<int> list = new List<int>();
15             //list.Add(1);
16             //list.Add(2);
17             //list.Add(3);
18 
19             //list.AddRange(new int[] { 1, 2, 3, 4, 5, 6 });
20             //list.AddRange(list);
21 
22             //List泛型集合可以转换为数组
23             //int[] nums = list.ToArray();
24 
25             //List<string> listStr = new List<string>();
26 
27             //string[] str = listStr.ToArray();
28 
29 
30             //char[] chs = new char[] { 'c', 'b', 'a' };
31             //List<char> listChar = chs.ToList();
32             //for (int i = 0; i < listChar.Count; i++)
33             //{
34             //    Console.WriteLine(listChar[i]);
35             //}
36 
37             ////   List<int> listTwo = nums.ToList();
38 
39 
40             //for (int i = 0; i < list.Count; i++)
41             //{
42             //    Console.WriteLine(list[i]);
43             //}
44             Console.ReadKey();
45         }
46     }
47 }
View Code

相关文章:

  • 2021-06-23
猜你喜欢
  • 2022-12-23
  • 2021-12-11
  • 2021-11-22
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案