NameValueCollection Klasse
Definition
public ref class NameValueCollection : System::Collections::Specialized::NameObjectCollectionBase
[System.Serializable]
public class NameValueCollection : System.Collections.Specialized.NameObjectCollectionBase
type NameValueCollection = class
inherit NameObjectCollectionBase
Public Class NameValueCollection
Inherits NameObjectCollectionBase
- Vererbung
- Abgeleitet
- Attribute
Beispiele
#using <System.dll>
using namespace System;
using namespace System::Collections;
using namespace System::Collections::Specialized;
void PrintKeysAndValues( NameValueCollection^ myCol );
void PrintKeysAndValues2( NameValueCollection^ myCol );
int main()
{
// Creates and initializes a new NameValueCollection.
NameValueCollection^ myCol = gcnew NameValueCollection;
myCol->Add( "red", "rojo" );
myCol->Add( "green", "verde" );
myCol->Add( "blue", "azul" );
myCol->Add( "red", "rouge" );
// Displays the values in the NameValueCollection in two different ways.
Console::WriteLine( "Displays the elements using the AllKeys property and the Item (indexer) property:" );
PrintKeysAndValues( myCol );
Console::WriteLine( "Displays the elements using GetKey and Get:" );
PrintKeysAndValues2( myCol );
// Gets a value either by index or by key.
Console::WriteLine( "Index 1 contains the value {0}.", myCol[ 1 ] );
Console::WriteLine( "Key \"red\" has the value {0}.", myCol[ "red" ] );
Console::WriteLine();
// Copies the values to a string array and displays the string array.
array<String^>^myStrArr = gcnew array<String^>(myCol->Count);
myCol->CopyTo( myStrArr, 0 );
Console::WriteLine( "The string array contains:" );
for each ( String^ s in myStrArr )
Console::WriteLine( " {0}", s );
Console::WriteLine();
// Searches for a key and deletes it.
myCol->Remove( "green" );
Console::WriteLine( "The collection contains the following elements after removing \"green\":" );
PrintKeysAndValues( myCol );
// Clears the entire collection.
myCol->Clear();
Console::WriteLine( "The collection contains the following elements after it is cleared:" );
PrintKeysAndValues( myCol );
}
void PrintKeysAndValues( NameValueCollection^ myCol )
{
Console::WriteLine( " KEY VALUE" );
for each ( String^ s in myCol->AllKeys )
Console::WriteLine( " {0,-10} {1}", s, myCol[s] );
Console::WriteLine();
}
void PrintKeysAndValues2( NameValueCollection^ myCol )
{
Console::WriteLine( " [INDEX] KEY VALUE" );
for ( int i = 0; i < myCol->Count; i++ )
Console::WriteLine( " [{0}] {1,-10} {2}", i, myCol->GetKey( i ), myCol->Get( i ) );
Console::WriteLine();
}
/*
This code produces the following output.
Displays the elements using the AllKeys property and the Item (indexer) property:
KEY VALUE
red rojo,rouge
green verde
blue azul
Displays the elements using GetKey and Get:
[INDEX] KEY VALUE
[0] red rojo,rouge
[1] green verde
[2] blue azul
Index 1 contains the value verde.
Key "red" has the value rojo,rouge.
The string array contains:
rojo,rouge
verde
azul
The collection contains the following elements after removing "green":
KEY VALUE
red rojo,rouge
blue azul
The collection contains the following elements after it is cleared:
KEY VALUE
*/
using System;
using System.Collections;
using System.Collections.Specialized;
public class SamplesNameValueCollection {
public static void Main() {
// Creates and initializes a new NameValueCollection.
NameValueCollection myCol = new NameValueCollection();
myCol.Add( "red", "rojo" );
myCol.Add( "green", "verde" );
myCol.Add( "blue", "azul" );
myCol.Add( "red", "rouge" );
// Displays the values in the NameValueCollection in two different ways.
Console.WriteLine( "Displays the elements using the AllKeys property and the Item (indexer) property:" );
PrintKeysAndValues( myCol );
Console.WriteLine( "Displays the elements using GetKey and Get:" );
PrintKeysAndValues2( myCol );
// Gets a value either by index or by key.
Console.WriteLine( "Index 1 contains the value {0}.", myCol[1] );
Console.WriteLine( "Key \"red\" has the value {0}.", myCol["red"] );
Console.WriteLine();
// Copies the values to a string array and displays the string array.
String[] myStrArr = new String[myCol.Count];
myCol.CopyTo( myStrArr, 0 );
Console.WriteLine( "The string array contains:" );
foreach ( String s in myStrArr )
Console.WriteLine( " {0}", s );
Console.WriteLine();
// Searches for a key and deletes it.
myCol.Remove( "green" );
Console.WriteLine( "The collection contains the following elements after removing \"green\":" );
PrintKeysAndValues( myCol );
// Clears the entire collection.
myCol.Clear();
Console.WriteLine( "The collection contains the following elements after it is cleared:" );
PrintKeysAndValues( myCol );
}
public static void PrintKeysAndValues( NameValueCollection myCol ) {
Console.WriteLine( " KEY VALUE" );
foreach ( String s in myCol.AllKeys )
Console.WriteLine( " {0,-10} {1}", s, myCol[s] );
Console.WriteLine();
}
public static void PrintKeysAndValues2( NameValueCollection myCol ) {
Console.WriteLine( " [INDEX] KEY VALUE" );
for ( int i = 0; i < myCol.Count; i++ )
Console.WriteLine( " [{0}] {1,-10} {2}", i, myCol.GetKey(i), myCol.Get(i) );
Console.WriteLine();
}
}
/*
This code produces the following output.
Displays the elements using the AllKeys property and the Item (indexer) property:
KEY VALUE
red rojo,rouge
green verde
blue azul
Displays the elements using GetKey and Get:
[INDEX] KEY VALUE
[0] red rojo,rouge
[1] green verde
[2] blue azul
Index 1 contains the value verde.
Key "red" has the value rojo,rouge.
The string array contains:
rojo,rouge
verde
azul
The collection contains the following elements after removing "green":
KEY VALUE
red rojo,rouge
blue azul
The collection contains the following elements after it is cleared:
KEY VALUE
*/
' The following code example demonstrates several of the properties and methods of ListDictionary.
Imports System.Collections
Imports System.Collections.Specialized
Public Class SamplesNameValueCollection
Public Shared Sub Main()
' Creates and initializes a new NameValueCollection.
Dim myCol As New NameValueCollection()
myCol.Add("red", "rojo")
myCol.Add("green", "verde")
myCol.Add("blue", "azul")
myCol.Add("red", "rouge")
' Displays the values in the NameValueCollection in two different ways.
Console.WriteLine("Displays the elements using the AllKeys property and the Item (indexer) property:")
PrintKeysAndValues(myCol)
Console.WriteLine("Displays the elements using GetKey and Get:")
PrintKeysAndValues2(myCol)
' Gets a value either by index or by key.
Console.WriteLine("Index 1 contains the value {0}.", myCol(1))
Console.WriteLine("Key ""red"" has the value {0}.", myCol("red"))
Console.WriteLine()
' Copies the values to a string array and displays the string array.
Dim myStrArr(myCol.Count) As String
myCol.CopyTo(myStrArr, 0)
Console.WriteLine("The string array contains:")
Dim s As String
For Each s In myStrArr
Console.WriteLine(" {0}", s)
Next s
Console.WriteLine()
' Searches for a key and deletes it.
myCol.Remove("green")
Console.WriteLine("The collection contains the following elements after removing ""green"":")
PrintKeysAndValues(myCol)
' Clears the entire collection.
myCol.Clear()
Console.WriteLine("The collection contains the following elements after it is cleared:")
PrintKeysAndValues(myCol)
End Sub
Public Shared Sub PrintKeysAndValues(myCol As NameValueCollection)
Console.WriteLine(" KEY VALUE")
Dim s As String
For Each s In myCol.AllKeys
Console.WriteLine(" {0,-10} {1}", s, myCol(s))
Next s
Console.WriteLine()
End Sub
Public Shared Sub PrintKeysAndValues2(myCol As NameValueCollection)
Console.WriteLine(" [INDEX] KEY VALUE")
Dim i As Integer
For i = 0 To myCol.Count - 1
Console.WriteLine(" [{0}] {1,-10} {2}", i, myCol.GetKey(i), myCol.Get(i))
Next i
Console.WriteLine()
End Sub
End Class
'This code produces the following output.
'
'Displays the elements using the AllKeys property and the Item (indexer) property:
' KEY VALUE
' red rojo,rouge
' green verde
' blue azul
'
'Displays the elements using GetKey and Get:
' [INDEX] KEY VALUE
' [0] red rojo,rouge
' [1] green verde
' [2] blue azul
'
'Index 1 contains the value verde.
'Key "red" has the value rojo,rouge.
'
'The string array contains:
' red
' green
' blue
'
'
'The collection contains the following elements after removing "green":
' KEY VALUE
' red rojo,rouge
' blue azul
'
'The collection contains the following elements after it is cleared:
' KEY VALUE
'
'
Hinweise
Diese Auflistung basiert auf der NameObjectCollectionBase -Klasse.This collection is based on the NameObjectCollectionBase class. Jedes Element der Auflistung ist ein Schlüssel-Wert-Paar.Each element of the collection is a key/value pair. Im Gegensatz zu NameObjectCollectionBasekann diese Klasse jedoch mehrere Zeichen folgen Werte unter einem einzelnen Schlüssel speichern.However, unlike the NameObjectCollectionBase, this class can store multiple string values under a single key.
Diese Klasse kann für Header, Abfrage Zeichenfolgen und Formulardaten verwendet werden.This class can be used for headers, query strings and form data.
Auflistungen dieses Typs behalten nicht die Reihenfolge der Elemente bei, und beim Auflisten der Auflistung ist keine bestimmte Reihenfolge garantiert.Collections of this type do not preserve the ordering of elements, and no particular ordering is guaranteed when enumerating the collection.
Die Kapazität NameValueCollection eines ist die Anzahl der Elemente, die NameValueCollection in der enthalten sein können.The capacity of a NameValueCollection is the number of elements the NameValueCollection can hold. Beim Hinzufügen von Elementen wird die Kapazität aufgrund der erneuten Zuordnung automatisch erhöht.As elements are added, its capacity is automatically increased as required through reallocation.
Der Hashcode-Anbieter gibt Hashcodes für Schlüssel in der NameValueCollectionaus.The hash code provider dispenses hash codes for keys in the NameValueCollection. Der standardmäßige Hashcode-Anbieter CaseInsensitiveHashCodeProviderist der.The default hash code provider is the CaseInsensitiveHashCodeProvider.
Der Vergleich bestimmt, ob zwei Schlüssel gleich sind.The comparer determines whether two keys are equal. Der Standardcomparer ist CaseInsensitiveComparer eine, die die Konventionen der invarianten Kulturverwendet, d. h., bei Schlüssel vergleichen wird die Groß-/Kleinschreibung standardmäßig nicht beachtet.The default comparer is a CaseInsensitiveComparer that uses the conventions of the invariant culture; that is, key comparisons are case-insensitive by default. Um Schlüssel Vergleiche mit Berücksichtigung der Groß-/Kleinschreibung durchzuführen NameValueCollection.NameValueCollection(IEqualityComparer) , müssen Sie den-Konstruktor und den StringComparer.CurrentCultureWert equalityComparer
, StringComparer.InvariantCultureoder StringComparer.Ordinal als-Argument angeben.To perform case-sensitive key comparisons, call the NameValueCollection.NameValueCollection(IEqualityComparer) constructor, and provide a value of StringComparer.CurrentCulture, StringComparer.InvariantCulture, or StringComparer.Ordinal as the equalityComparer
argument. Weitere Informationen dazu, wie sich die Kultur auf Vergleiche und Sortierungen auswirkt, finden Sie unter durchführen Kultur unabhängiger Zeichen folgen Operationen.For more information about how culture affects comparisons and sorting, see Performing Culture-Insensitive String Operations.
null
ist als Schlüssel oder als Wert zulässig.null
is allowed as a key or as a value.
Achtung
Die Get -Methode unterscheidet nicht null
zwischen dem zurückgegebenen, weil der angegebene Schlüssel nicht gefunden null
wurde und der zurückgegeben wird, da der Wert, null
der dem Schlüssel zugeordnet ist, ist.The Get method does not distinguish between null
which is returned because the specified key is not found and null
which is returned because the value associated with the key is null
.
Konstruktoren
NameValueCollection() |
Initialisiert eine neue, leere Instanz der NameValueCollection-Klasse mit der anfänglichen Standardkapazität, wobei der Hashcode-Standardanbieter und Standardcomparer verwendet werden, die beide die Groß- und Kleinschreibung nicht berücksichtigen.Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer. |
NameValueCollection(IEqualityComparer) |
Initialisiert eine neue, leere Instanz der NameValueCollection-Klasse mit der anfänglichen Standardkapazität und dem angegebenen IEqualityComparer-Objekt.Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity, and uses the specified IEqualityComparer object. |
NameValueCollection(IHashCodeProvider, IComparer) |
Initialisiert eine neue, leere Instanz der NameValueCollection-Klasse mit der anfänglichen Standardkapazität, wobei der angegebene Hashcodeanbieter und Comparer verwendet werden.Initializes a new instance of the NameValueCollection class that is empty, has the default initial capacity and uses the specified hash code provider and the specified comparer. |
NameValueCollection(Int32) |
Initialisiert eine neue, leere Instanz der NameValueCollection-Klasse mit der angegebenen Anfangskapazität, wobei der Hashcode-Standardanbieter und der Standardcomparer verwendet werden, die beide die Groß- und Kleinschreibung nicht berücksichtigen.Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity and uses the default case-insensitive hash code provider and the default case-insensitive comparer. |
NameValueCollection(Int32, IEqualityComparer) |
Initialisiert eine neue, leere Instanz der NameValueCollection-Klasse mit der angegebenen Anfangskapazität und dem angegebenen IEqualityComparer-Objekt.Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity, and uses the specified IEqualityComparer object. |
NameValueCollection(Int32, IHashCodeProvider, IComparer) |
Initialisiert eine neue, leere Instanz der NameValueCollection-Klasse mit der angegebenen Anfangskapazität, wobei der angegebene Hashcodeanbieter und Comparer verwendet werden.Initializes a new instance of the NameValueCollection class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer. |
NameValueCollection(Int32, NameValueCollection) |
Kopiert die Einträge aus der angegebenen NameValueCollection in eine neue NameValueCollection mit der angegebenen Anfangskapazität bzw. mit einer Anfangskapazität, die der Anzahl der kopierten Einträge entspricht, je nachdem, welche größer ist. Es werden der Hashcode-Standardanbieter und der Standardcomparer verwendet, die die Groß- und Kleinschreibung nicht berücksichtigen.Copies the entries from the specified NameValueCollection to a new NameValueCollection with the specified initial capacity or the same initial capacity as the number of entries copied, whichever is greater, and using the default case-insensitive hash code provider and the default case-insensitive comparer. |
NameValueCollection(NameValueCollection) |
Kopiert die Einträge aus der angegebenen NameValueCollection in eine neue NameValueCollection, deren Anfangskapazität der Anzahl der kopierten Einträge entspricht, und verwendet denselben Hashcodeanbieter und Comparer wie die Quellauflistung.Copies the entries from the specified NameValueCollection to a new NameValueCollection with the same initial capacity as the number of entries copied and using the same hash code provider and the same comparer as the source collection. |
NameValueCollection(SerializationInfo, StreamingContext) |
Initialisiert eine neue Instanz der NameValueCollection-Klasse, die serialisierbar ist und die angegebene SerializationInfo und den angegebenen StreamingContext verwendet.Initializes a new instance of the NameValueCollection class that is serializable and uses the specified SerializationInfo and StreamingContext. |
Eigenschaften
AllKeys |
Ruft alle Schlüssel in der NameValueCollection-Instanz ab.Gets all the keys in the NameValueCollection. |
Count |
Ruft die Anzahl von Schlüssel-Wert-Paaren in der NameObjectCollectionBase-Instanz ab.Gets the number of key/value pairs contained in the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
IsReadOnly |
Ruft einen Wert ab, der angibt, ob die NameObjectCollectionBase-Instanz schreibgeschützt ist, oder legt diesen fest.Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only. (Geerbt von NameObjectCollectionBase) |
Item[Int32] |
Ruft den Eintrag am angegebenen Index von NameValueCollection ab.Gets the entry at the specified index of the NameValueCollection. |
Item[String] |
Ruft den Eintrag mit dem angegebenen Schlüssel in NameValueCollection ab oder legt diesen fest.Gets or sets the entry with the specified key in the NameValueCollection. |
Keys |
Ruft eine NameObjectCollectionBase.KeysCollection-Instanz ab, die alle Schlüssel der NameObjectCollectionBase-Instanz enthält.Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
Methoden
Add(NameValueCollection) |
Kopiert die Einträge in der angegebenen NameValueCollection in die aktuelle NameValueCollection.Copies the entries in the specified NameValueCollection to the current NameValueCollection. |
Add(String, String) |
Fügt der NameValueCollection-Instanz einen Eintrag mit dem angegebenen Schlüssel und Wert hinzu.Adds an entry with the specified name and value to the NameValueCollection. |
BaseAdd(String, Object) |
Fügt einen Eintrag mit dem angegebenen Schlüssel und Wert der NameObjectCollectionBase-Instanz hinzu.Adds an entry with the specified key and value into the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseClear() |
Entfernt alle Einträge aus der NameObjectCollectionBase-Instanz.Removes all entries from the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseGet(Int32) |
Ruft den Wert des Eintrags am angegebenen Index der NameObjectCollectionBase-Instanz ab.Gets the value of the entry at the specified index of the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseGet(String) |
Ruft den Wert des ersten Eintrags mit dem angegebenen Schlüssel aus der NameObjectCollectionBase-Instanz ab.Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseGetAllKeys() |
Gibt ein String-Array zurück, das alle Schlüssel der NameObjectCollectionBase-Instanz enthält.Returns a String array that contains all the keys in the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseGetAllValues() |
Gibt ein Object-Array zurück, das alle Werte der NameObjectCollectionBase-Instanz enthält.Returns an Object array that contains all the values in the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseGetAllValues(Type) |
Gibt ein Array des angegebenen Typs zurück, das alle Werte der NameObjectCollectionBase-Instanz enthält.Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseGetKey(Int32) |
Ruft den Schlüssel des Eintrags am angegebenen Index der NameObjectCollectionBase-Instanz ab.Gets the key of the entry at the specified index of the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseHasKeys() |
Ruft einen Wert ab, der angibt, ob die NameObjectCollectionBase-Instanz Einträge enthält, deren Schlüssel nicht |
BaseRemove(String) |
Entfernt die Einträge mit dem angegebenen Schlüssel aus der NameObjectCollectionBase-Instanz.Removes the entries with the specified key from the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseRemoveAt(Int32) |
Entfernt den Eintrag am angegebenen Index der NameObjectCollectionBase-Instanz.Removes the entry at the specified index of the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseSet(Int32, Object) |
Legt den Wert des Eintrags am angegebenen Index der NameObjectCollectionBase-Instanz fest.Sets the value of the entry at the specified index of the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
BaseSet(String, Object) |
Legt den Wert des ersten Eintrags mit dem angegebenen Schlüssel in der NameObjectCollectionBase-Instanz fest. Wenn der Schlüssel nicht vorhanden ist, wird der NameObjectCollectionBase-Instanz ein Eintrag mit dem angegebenen Wert und Schlüssel hinzugefügt.Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
Clear() |
Erklärt die zwischengespeicherten Arrays für ungültig und entfernt alle Einträge aus der NameValueCollection-Instanz.Invalidates the cached arrays and removes all entries from the NameValueCollection. |
CopyTo(Array, Int32) |
Kopiert die gesamte NameValueCollection-Instanz in ein kompatibles eindimensionales Array, beginnend am angegebenen Index des Zielarrays.Copies the entire NameValueCollection to a compatible one-dimensional Array, starting at the specified index of the target array. |
Equals(Object) |
Ermittelt, ob das angegebene Objekt und das aktuelle Objekt gleich sind.Determines whether the specified object is equal to the current object. (Geerbt von Object) |
Get(Int32) |
Ruft die Werte am angegebenen Index von NameValueCollection ab, die in einer einzigen, durch Trennzeichen getrennten Liste zusammengefasst werden.Gets the values at the specified index of the NameValueCollection combined into one comma-separated list. |
Get(String) |
Ruft die dem angegebenen Schlüssel zugeordneten Werte aus NameValueCollection ab, die in einer einzigen, durch Trennzeichen getrennten Liste zusammengefasst werden.Gets the values associated with the specified key from the NameValueCollection combined into one comma-separated list. |
GetEnumerator() |
Gibt einen Enumerator zurück, der die NameObjectCollectionBase durchläuft.Returns an enumerator that iterates through the NameObjectCollectionBase. (Geerbt von NameObjectCollectionBase) |
GetHashCode() |
Dient als die Standard-HashfunktionServes as the default hash function. (Geerbt von Object) |
GetKey(Int32) |
Ruft den Schlüssel am angegebenen Index von NameValueCollection ab.Gets the key at the specified index of the NameValueCollection. |
GetObjectData(SerializationInfo, StreamingContext) |
Implementiert die ISerializable-Schnittstelle und gibt die zum Serialisieren der NameObjectCollectionBase-Instanz erforderlichen Daten zurück.Implements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance. (Geerbt von NameObjectCollectionBase) |
GetType() |
Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance. (Geerbt von Object) |
GetValues(Int32) |
Ruft die Werte am angegebenen Index von NameValueCollection ab.Gets the values at the specified index of the NameValueCollection. |
GetValues(String) |
Ruft aus NameValueCollection die Werte ab, die dem angegebenen Schlüssel zugeordnet sind.Gets the values associated with the specified key from the NameValueCollection. |
HasKeys() |
Ruft einen Wert ab, der angibt, ob die NameValueCollection-Instanz Schlüssel enthält, die nicht |
InvalidateCachedArrays() |
Setzt die zwischengespeicherten Arrays der Auflistung auf |
MemberwiseClone() |
Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object. (Geerbt von Object) |
OnDeserialization(Object) |
Implementiert die ISerializable-Schnittstelle und löst das Deserialisierungsereignis aus, sobald die Deserialisierung abgeschlossen ist.Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. (Geerbt von NameObjectCollectionBase) |
Remove(String) |
Entfernt die Einträge mit dem angegebenen Schlüssel aus der NameObjectCollectionBase-Instanz.Removes the entries with the specified key from the NameObjectCollectionBase instance. |
Set(String, String) |
Legt den Wert eines Eintrags in NameValueCollection fest.Sets the value of an entry in the NameValueCollection. |
ToString() |
Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object. (Geerbt von Object) |
Explizite Schnittstellenimplementierungen
ICollection.CopyTo(Array, Int32) |
Kopiert die gesamte NameObjectCollectionBase-Instanz in ein kompatibles eindimensionales Array, beginnend am angegebenen Index des Zielarrays.Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Geerbt von NameObjectCollectionBase) |
ICollection.IsSynchronized |
Ruft einen Wert ab, der angibt, ob der Zugriff auf das NameObjectCollectionBase-Objekt synchronisiert (threadsicher) ist.Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe). (Geerbt von NameObjectCollectionBase) |
ICollection.SyncRoot |
Ruft ein Objekt ab, mit dem der Zugriff auf das NameObjectCollectionBase-Objekt synchronisiert werden kann.Gets an object that can be used to synchronize access to the NameObjectCollectionBase object. (Geerbt von NameObjectCollectionBase) |
Erweiterungsmethoden
Cast<TResult>(IEnumerable) |
Wandelt die Elemente eines IEnumerable in den angegebenen Typ umCasts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filtert die Elemente eines IEnumerable anhand eines angegebenen TypsFilters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Ermöglicht die Parallelisierung einer Abfrage.Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Konvertiert einen IEnumerable in einen IQueryable.Converts an IEnumerable to an IQueryable. |
Gilt für:
Threadsicherheit
Öffentliche statische (Shared
in Visual Basic) Member dieses Typs sind Thread sicher.Public static (Shared
in Visual Basic) members of this type are thread safe. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.Any instance members are not guaranteed to be thread safe.
Diese Implementierung stellt NameValueCollectionkeinen synchronisierten (Thread sicheren) Wrapper für eine bereit, aber abgeleitete Klassen können NameValueCollection NameObjectCollectionBase mithilfe der SyncRoot -Eigenschaft der-Klasse eigene synchronisierte Versionen von erstellen.This implementation does not provide a synchronized (thread safe) wrapper for a NameValueCollection, but derived classes can create their own synchronized versions of the NameValueCollection using the SyncRoot property of the NameObjectCollectionBase class.
Das Auflisten durch eine Auflistung ist intrinsisch keine Thread sichere Prozedur.Enumerating through a collection is intrinsically not a thread safe procedure. Selbst wenn eine Auflistung synchronisiert wird, besteht die Möglichkeit, dass andere Threads sie ändern. Dies führt dazu, dass der Enumerator eine Ausnahme auslöst.Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. Um während der Enumeration Threadsicherheit zu gewährleisten, können Sie entweder die Auflistung während der gesamten Enumeration sperren oder die Ausnahmen, die aus von anderen Threads stammenden Änderungen resultieren, abfangen.To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.