创建泛类集合List以及数组转集合,集合转数组的应用

时间:2022-12-23 17:04:44
            List<int> list = new List<int>();
list.Add();
list.Add();
list.Add();
list.AddRange(new int[] { , , , , , });
int[] nums=list.ToArray(); //集合转数组
for (int i = ; i < list.Count; i++)
{
Console.WriteLine(list[i]);
}
char[] chs = new char[] { 'a','b','c'};
List<char> listchar = chs.ToList();//char 类型数组转集合
for (int i = ; i < list.Count; i++)
{
Console.WriteLine(listchar[i]);
}
Console.ReadLine();