链表集合List
//链表可以加多个元素
using System; using System.Collections.Generic; public class studyList { public static void Main() { List<string> list = new List<string>(); list.Add("sdhguew"); //链表可以加多个元素 List<string> list1 = new List<string>(); list1.Add("苹果"); list1.Add("橘子"); list1.Add("桃"); list1.Add("李子"); list.AddRange(list1); //判断是否存在 if(list.Contains("葡萄")) { Console.WriteLine("存在"); } else { Console.WriteLine("不存在"); } list.Insert(3,"哈密瓜"); list.Insert(4,"提子"); foreach(string s in list) { Console.WriteLine(s); } //插入数据 //list.Insert(4,"98"); //计数 Console.WriteLine(list1.Count); list.RemoveRange(2,2); Console.WriteLine(list.Count); foreach(string s in list) { Console.WriteLine(s); } } }