C#中的LinkedList
System.Collections.Generic命名空间在C#中可用于LinkedList。LinkedList<T>类允许快速从列表中插入和删除元素。
C#LinkedList<T>类使用链接列表的概念。它使我们能够快速插入和删除元素。它可以具有重复的元素。在System.Collections.Generic命名空间中找到它。
这是一个例子-
示例
using System; using System.Collections.Generic; class Demo { static void Main() { LinkedList < string > l = new LinkedList < string > (); l.AddLast("one"); l.AddLast("two"); l.AddLast("three"); foreach(var ele in l) { Console.WriteLine(ele); } } }
输出结果
one two three