C# 中的連結串列
LinkedList 屬於 C# 中可用的 System.Collections.Generic 名稱空間。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
廣告