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

更新时间:2020-06-22

2000+ 次浏览

开启你的 职业生涯

完成课程即可获得认证

开始
广告
© . All rights reserved.