LinkedList<T> Konstruktory
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Inicjuje nowe wystąpienie klasy LinkedList<T>.
Przeciążenia
| Nazwa | Opis |
|---|---|
| LinkedList<T>() |
Inicjuje LinkedList<T> nowe wystąpienie klasy, która jest pusta. |
| LinkedList<T>(IEnumerable<T>) |
Inicjuje nowe wystąpienie LinkedList<T> klasy zawierające elementy skopiowane z określonego IEnumerable obiektu i ma wystarczającą pojemność, aby pomieścić liczbę skopiowanych elementów. |
| LinkedList<T>(SerializationInfo, StreamingContext) |
Przestarzałe.
Inicjuje LinkedList<T> nowe wystąpienie klasy, które można serializować przy użyciu określonych SerializationInfo i StreamingContext. |
LinkedList<T>()
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
Inicjuje LinkedList<T> nowe wystąpienie klasy, która jest pusta.
public:
LinkedList();
public LinkedList();
Public Sub New ()
Przykłady
Poniższy przykład kodu tworzy i inicjuje LinkedList<T> typ String, dodaje kilka węzłów, a następnie wyświetla jego zawartość.
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.");
}
}
}
/* This code produces the following output.
The first item in the list is red.
The last item in the list is orange.
The LinkedList contains:
red
orange
yellow
orange
*/
Imports System.Collections
Imports System.Collections.Generic
Public Class GenericCollection
Public Shared Sub Main()
' Create and initialize a new LinkedList.
Dim ll As New LinkedList(Of String)()
ll.AddLast("red")
ll.AddLast("orange")
ll.AddLast("yellow")
ll.AddLast("orange")
' Display the contents of the LinkedList.
If ll.Count > 0 Then
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:")
For Each s As String In ll
Console.WriteLine(" {0}", s)
Next s
Else
Console.WriteLine("The LinkedList is empty.")
End If
End Sub
End Class
'This code produces the following output.
'
'The first item in the list is red.
'The last item in the list is orange.
'The LinkedList contains:
' red
' orange
' yellow
' orange
Uwagi
LinkedList<T>
null akceptuje jako prawidłowy Value dla typów odwołań i zezwala na zduplikowane wartości.
Jeśli właściwość jest pusta LinkedList<T> , First właściwości i Last zawierają nullwartość .
Ten konstruktor jest operacją O(1).
Dotyczy
LinkedList<T>(IEnumerable<T>)
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
Inicjuje nowe wystąpienie LinkedList<T> klasy zawierające elementy skopiowane z określonego IEnumerable obiektu i ma wystarczającą pojemność, aby pomieścić liczbę skopiowanych elementów.
public:
LinkedList(System::Collections::Generic::IEnumerable<T> ^ collection);
public LinkedList(System.Collections.Generic.IEnumerable<T> collection);
new System.Collections.Generic.LinkedList<'T> : seq<'T> -> System.Collections.Generic.LinkedList<'T>
Public Sub New (collection As IEnumerable(Of T))
Parametry
- collection
- IEnumerable<T>
Element IEnumerable , którego elementy są kopiowane do nowego LinkedList<T>elementu .
Wyjątki
Parametr collection ma wartość null.
Przykłady
Aby zapoznać się z przykładem obejmującym ten konstruktor, zobacz klasę LinkedList<T> .
Uwagi
LinkedList<T>
null akceptuje jako prawidłowy Value dla typów odwołań i zezwala na zduplikowane wartości.
Jeśli collection nie ma żadnych elementów, nowy LinkedList<T> jest pusty, a First właściwości i Last zawierają null.
Ten konstruktor jest operacją O(n), gdzie n jest liczbą elementów w .collection
Dotyczy
LinkedList<T>(SerializationInfo, StreamingContext)
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
- Źródło:
- LinkedList.cs
Uwaga
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
Inicjuje LinkedList<T> nowe wystąpienie klasy, które można serializować przy użyciu określonych SerializationInfo i StreamingContext.
protected:
LinkedList(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected LinkedList(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected LinkedList(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Collections.Generic.LinkedList<'T> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.LinkedList<'T>
new System.Collections.Generic.LinkedList<'T> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.LinkedList<'T>
Protected Sub New (info As SerializationInfo, context As StreamingContext)
Parametry
- info
- SerializationInfo
SerializationInfo Obiekt zawierający informacje wymagane do serializacji obiektu LinkedList<T>.
- context
- StreamingContext
StreamingContext Obiekt zawierający źródło i miejsce docelowe serializowanego strumienia skojarzonego z obiektem LinkedList<T>.
- Atrybuty
Uwagi
LinkedList<T>
null akceptuje jako prawidłowy Value dla typów odwołań i zezwala na zduplikowane wartości.
Jeśli właściwość jest pusta LinkedList<T> , First właściwości i Last zawierają nullwartość .
Ten konstruktor jest operacją O(n).