C# 中的連結串列
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
廣告