本文整理匯總了C#中System.Collections.Generic.LinkedList<T>.LinkedList構造函數的典型用法代碼示例。如果您正苦於以下問題:C# LinkedList<T>構造函數的具體用法?C# LinkedList<T>怎麽用?C# LinkedList<T>使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。您也可以進一步了解該構造函數所在類System.Collections.Generic.LinkedList<T>
的用法示例。
在下文中一共展示了LinkedList<T>構造函數的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Collections;
using System.Collections.Generic;
public class GenericCollection
{
public static void Main()
{
// Create and initialize a new LinkedList.
LinkedList<String> ll = new LinkedList<String>();
ll.AddLast("red");
ll.AddLast("orange");
ll.AddLast("yellow");
ll.AddLast("orange");
// Display the contents of the LinkedList.
if (ll.Count > 0)
{
Console.WriteLine("The first item in the list is {0}.", ll.First.Value);
Console.WriteLine("The last item in the list is {0}.", ll.Last.Value);
Console.WriteLine("The LinkedList contains:");
foreach (String s in ll)
Console.WriteLine(" {0}", s);
}
else
{
Console.WriteLine("The LinkedList is empty.");
}
}
}
輸出:
The first item in the list is red. The last item in the list is orange. The LinkedList contains: red orange yellow orange