【C#学习笔记】LinkedList容器使用
using System; using System.Collections.Generic; namespace ConsoleApplication { class Program { static void Main(string[] args) { LinkedList<int> a = new LinkedList<int>(); a.AddFirst(3); a.AddLast(1); a.AddLast(4); foreach (int i in a) Console.Write(i + " "); Console.WriteLine(); LinkedListNode<int> cur = a.Find(3); //cur对应3所在的位置 a.AddBefore(cur, 2); //在3前面添加2 foreach (int i in a) Console.Write(i + " "); a.Remove(3); a.Clear(); Console.Read(); } } }