使用X#中的LinkedList集合声明一个LinkedList-
var a = new LinkedList < string > ();
现在将元素添加到LinkedList-
a.AddLast("Tim"); a.AddLast("Tom");
让我们看看如何在LinkedList中执行遍历-
using System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { var a = new LinkedList < string > (); a.AddLast("Tim"); a.AddLast("Tom"); foreach(var res in a) { Console.WriteLine(res); } } }