HashSet<T> Constructores

Definición

Inicializa una nueva instancia de la clase HashSet<T>.Initializes a new instance of the HashSet<T> class.

Sobrecargas

HashSet<T>()

Inicializa una nueva instancia de la clase HashSet<T> que está vacía y utiliza el comparador de igualdad predeterminado para el tipo de conjunto.Initializes a new instance of the HashSet<T> class that is empty and uses the default equality comparer for the set type.

HashSet<T>(IEnumerable<T>)

Inicializa una nueva instancia de la clase HashSet<T> que utiliza el comparador de igualdad predeterminado para el tipo de conjunto, contiene elementos copiados de la colección especificada y tiene capacidad suficiente para dar cabida al número de elementos copiados.Initializes a new instance of the HashSet<T> class that uses the default equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

HashSet<T>(IEqualityComparer<T>)

Inicializa una nueva instancia de la clase HashSet<T> que está vacía y utiliza el comparador de igualdad especificado para el tipo de conjunto.Initializes a new instance of the HashSet<T> class that is empty and uses the specified equality comparer for the set type.

HashSet<T>(Int32)

Inicializa una nueva instancia de la clase HashSet<T> que está vacía, pero que tiene espacio reservado para los elementos capacity y usa el comparador de igualdad predeterminado para el tipo de conjunto.Initializes a new instance of the HashSet<T> class that is empty, but has reserved space for capacity items and uses the default equality comparer for the set type.

HashSet<T>(IEnumerable<T>, IEqualityComparer<T>)

Inicializa una nueva instancia de la clase HashSet<T> que utiliza el comparador de igualdad especificado para el tipo de conjunto, contiene elementos copiados de la colección especificada y tiene capacidad suficiente para alojar el número de elementos copiados.Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

HashSet<T>(Int32, IEqualityComparer<T>)

Inicializa una nueva instancia de la clase HashSet<T> que usa el comparador de igualdad especificado para el tipo de conjunto y que tiene capacidad suficiente para alojar elementos capacity.Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, and has sufficient capacity to accommodate capacity elements.

HashSet<T>(SerializationInfo, StreamingContext)

Inicializa una nueva instancia de la clase HashSet<T> con datos serializados.Initializes a new instance of the HashSet<T> class with serialized data.

HashSet<T>()

Inicializa una nueva instancia de la clase HashSet<T> que está vacía y utiliza el comparador de igualdad predeterminado para el tipo de conjunto.Initializes a new instance of the HashSet<T> class that is empty and uses the default equality comparer for the set type.

public:
 HashSet();
public HashSet ();
Public Sub New ()

Ejemplos

En el ejemplo siguiente se muestra cómo crear y rellenar dos objetos HashSet<T>.The following example demonstrates how to create and populate two HashSet<T> objects. Este ejemplo forma parte de un ejemplo mayor proporcionado para el método UnionWith.This example is part of a larger example provided for the UnionWith method.

HashSet<int> evenNumbers = new HashSet<int>();
HashSet<int> oddNumbers = new HashSet<int>();

for (int i = 0; i < 5; i++)
{
    // Populate numbers with just even numbers.
    evenNumbers.Add(i * 2);

    // Populate oddNumbers with just odd numbers.
    oddNumbers.Add((i * 2) + 1);
}

Comentarios

La capacidad de un objeto HashSet<T> es el número de elementos que puede contener el objeto.The capacity of a HashSet<T> object is the number of elements that the object can hold. La capacidad de un objeto HashSet<T> aumenta automáticamente a medida que se agregan elementos al objeto.A HashSet<T> object's capacity automatically increases as elements are added to the object.

Este constructor es una operación O (1).This constructor is an O(1) operation.

HashSet<T>(IEnumerable<T>)

Inicializa una nueva instancia de la clase HashSet<T> que utiliza el comparador de igualdad predeterminado para el tipo de conjunto, contiene elementos copiados de la colección especificada y tiene capacidad suficiente para dar cabida al número de elementos copiados.Initializes a new instance of the HashSet<T> class that uses the default equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

public:
 HashSet(System::Collections::Generic::IEnumerable<T> ^ collection);
public HashSet (System.Collections.Generic.IEnumerable<T> collection);
new System.Collections.Generic.HashSet<'T> : seq<'T> -> System.Collections.Generic.HashSet<'T>
Public Sub New (collection As IEnumerable(Of T))

Parámetros

collection
IEnumerable<T>

Colección cuyos elementos se copian en el nuevo conjunto.The collection whose elements are copied to the new set.

Excepciones

collection es null.collection is null.

Ejemplos

En el ejemplo siguiente se muestra cómo crear una colección HashSet<T> a partir de un conjunto existente.The following example shows how to create a HashSet<T> collection from an existing set. En este ejemplo, se crean dos conjuntos con enteros pares e impares, respectivamente.In this example, two sets are created with even and odd integers, respectively. A continuación, se crea un tercer objeto HashSet<T> a partir del conjunto de enteros pares.A third HashSet<T> object is then created from the even integer set.

HashSet<int> evenNumbers = new HashSet<int>();
HashSet<int> oddNumbers = new HashSet<int>();

for (int i = 0; i < 5; i++)
{
    // Populate numbers with just even numbers.
    evenNumbers.Add(i * 2);

    // Populate oddNumbers with just odd numbers.
    oddNumbers.Add((i * 2) + 1);
}

Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count);
DisplaySet(evenNumbers);

Console.Write("oddNumbers contains {0} elements: ", oddNumbers.Count);
DisplaySet(oddNumbers);

// Create a new HashSet populated with even numbers.
HashSet<int> numbers = new HashSet<int>(evenNumbers);
Console.WriteLine("numbers UnionWith oddNumbers...");
numbers.UnionWith(oddNumbers);

Console.Write("numbers contains {0} elements: ", numbers.Count);
DisplaySet(numbers);

void DisplaySet(HashSet<int> set)
{
    Console.Write("{");
    foreach (int i in set)
    {
        Console.Write(" {0}", i);
    }
    Console.WriteLine(" }");
}

/* This example produces output similar to the following:
* evenNumbers contains 5 elements: { 0 2 4 6 8 }
* oddNumbers contains 5 elements: { 1 3 5 7 9 }
* numbers UnionWith oddNumbers...
* numbers contains 10 elements: { 0 2 4 6 8 1 3 5 7 9 }
*/
Shared Sub Main()

    Dim evenNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()
    Dim oddNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()

    For i As Integer = 0 To 4

        ' Populate evenNumbers with only even numbers.
        evenNumbers.Add(i * 2)

        ' Populate oddNumbers with only odd numbers.
        oddNumbers.Add((i * 2) + 1)
    Next i

    Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count)
    DisplaySet(evenNumbers)

    Console.Write("oddNumbers contains {0} elements: ", oddNumbers.Count)
    DisplaySet(oddNumbers)

    ' Create a new HashSet populated with even numbers.
    Dim numbers As HashSet(Of Integer) = New HashSet(Of Integer)(evenNumbers)
    Console.WriteLine("numbers UnionWith oddNumbers...")
    numbers.UnionWith(oddNumbers)

    Console.Write("numbers contains {0} elements: ", numbers.Count)
    DisplaySet(numbers)
End Sub

Comentarios

La capacidad de un objeto HashSet<T> es el número de elementos que puede contener el objeto.The capacity of a HashSet<T> object is the number of elements that the object can hold. La capacidad de un objeto HashSet<T> aumenta automáticamente a medida que se agregan elementos al objeto.A HashSet<T> object's capacity automatically increases as elements are added to the object.

Si collection contiene duplicados, el conjunto contendrá uno de cada elemento único.If collection contains duplicates, the set will contain one of each unique element. No se producirá ninguna excepción.No exception will be thrown. Por lo tanto, el tamaño del conjunto resultante no es idéntico al tamaño de collection.Therefore, the size of the resulting set is not identical to the size of collection.

Este constructor es una operación O (n), donde n es el número de elementos del parámetro collection.This constructor is an O(n) operation, where n is the number of elements in the collection parameter.

HashSet<T>(IEqualityComparer<T>)

Inicializa una nueva instancia de la clase HashSet<T> que está vacía y utiliza el comparador de igualdad especificado para el tipo de conjunto.Initializes a new instance of the HashSet<T> class that is empty and uses the specified equality comparer for the set type.

public:
 HashSet(System::Collections::Generic::IEqualityComparer<T> ^ comparer);
public HashSet (System.Collections.Generic.IEqualityComparer<T> comparer);
new System.Collections.Generic.HashSet<'T> : System.Collections.Generic.IEqualityComparer<'T> -> System.Collections.Generic.HashSet<'T>
Public Sub New (comparer As IEqualityComparer(Of T))

Parámetros

comparer
IEqualityComparer<T>

Implementación de IEqualityComparer<T> que se va a usar para comparar valores del conjunto o null si se va a usar la implementación de EqualityComparer<T> predeterminada para el tipo de conjunto.The IEqualityComparer<T> implementation to use when comparing values in the set, or null to use the default EqualityComparer<T> implementation for the set type.

Comentarios

La capacidad de un objeto HashSet<T> es el número de elementos que puede contener el objeto.The capacity of a HashSet<T> object is the number of elements that the object can hold. La capacidad de un objeto HashSet<T> aumenta automáticamente a medida que se agregan elementos al objeto.A HashSet<T> object's capacity automatically increases as elements are added to the object.

Este constructor es una operación O (1).This constructor is an O(1) operation.

HashSet<T>(Int32)

Inicializa una nueva instancia de la clase HashSet<T> que está vacía, pero que tiene espacio reservado para los elementos capacity y usa el comparador de igualdad predeterminado para el tipo de conjunto.Initializes a new instance of the HashSet<T> class that is empty, but has reserved space for capacity items and uses the default equality comparer for the set type.

public:
 HashSet(int capacity);
public HashSet (int capacity);
new System.Collections.Generic.HashSet<'T> : int -> System.Collections.Generic.HashSet<'T>
Public Sub New (capacity As Integer)

Parámetros

capacity
Int32

Tamaño inicial de HashSet<T>.The initial size of the HashSet<T>

Comentarios

Dado que los redimensionamientos son relativamente caros (requieren un rehash), intenta minimizar la necesidad de cambiar el tamaño estableciendo la capacidad inicial según el valor de la capacity.Since resizes are relatively expensive (require rehashing), this attempts to minimize the need to resize by setting the initial capacity based on the value of the capacity.

HashSet<T>(IEnumerable<T>, IEqualityComparer<T>)

Inicializa una nueva instancia de la clase HashSet<T> que utiliza el comparador de igualdad especificado para el tipo de conjunto, contiene elementos copiados de la colección especificada y tiene capacidad suficiente para alojar el número de elementos copiados.Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

public:
 HashSet(System::Collections::Generic::IEnumerable<T> ^ collection, System::Collections::Generic::IEqualityComparer<T> ^ comparer);
public HashSet (System.Collections.Generic.IEnumerable<T> collection, System.Collections.Generic.IEqualityComparer<T> comparer);
new System.Collections.Generic.HashSet<'T> : seq<'T> * System.Collections.Generic.IEqualityComparer<'T> -> System.Collections.Generic.HashSet<'T>
Public Sub New (collection As IEnumerable(Of T), comparer As IEqualityComparer(Of T))

Parámetros

collection
IEnumerable<T>

Colección cuyos elementos se copian en el nuevo conjunto.The collection whose elements are copied to the new set.

comparer
IEqualityComparer<T>

Implementación de IEqualityComparer<T> que se va a usar para comparar valores del conjunto o null si se va a usar la implementación de EqualityComparer<T> predeterminada para el tipo de conjunto.The IEqualityComparer<T> implementation to use when comparing values in the set, or null to use the default EqualityComparer<T> implementation for the set type.

Excepciones

collection es null.collection is null.

Ejemplos

En el ejemplo siguiente se usa un IEqualityComparer<T> proporcionado para permitir comparaciones sin distinción entre mayúsculas y minúsculas en los elementos de una colección HashSet<T> de tipos de vehículos.The following example uses a supplied IEqualityComparer<T> to allow case-insensitive comparisons on the elements of a HashSet<T> collection of vehicle types.

#using <System.Core.dll>

using namespace System;
using namespace System::Collections::Generic;

ref class Program
{
public:
    static void Main()
    {
        HashSet<String^> ^allVehicles = gcnew HashSet<String^>(StringComparer::OrdinalIgnoreCase);
        List<String^>^ someVehicles = gcnew List<String^>();

        someVehicles->Add("Planes");
        someVehicles->Add("Trains");
        someVehicles->Add("Automobiles");

        // Add in the vehicles contained in the someVehicles list.
        allVehicles->UnionWith(someVehicles);

        Console::WriteLine("The current HashSet contains:\n");
        for each (String^ vehicle in allVehicles)
        {
            Console::WriteLine(vehicle);
        }

        allVehicles->Add("Ships");
        allVehicles->Add("Motorcycles");
        allVehicles->Add("Rockets");
        allVehicles->Add("Helicopters");
        allVehicles->Add("Submarines");

        Console::WriteLine("\nThe updated HashSet contains:\n");
        for each (String^ vehicle in allVehicles)
        {
            Console::WriteLine(vehicle);
        }

        // Verify that the 'All Vehicles' set contains at least the vehicles in
        // the 'Some Vehicles' list.
        if (allVehicles->IsSupersetOf(someVehicles))
        {
            Console::Write("\nThe 'All' vehicles set contains everything in ");
            Console::WriteLine("'Some' vechicles list.");
        }

        // Check for Rockets. Here the OrdinalIgnoreCase comparer will compare
        // true for the mixed-case vehicle type.
        if (allVehicles->Contains("roCKeTs"))
        {
            Console::WriteLine("\nThe 'All' vehicles set contains 'roCKeTs'");
        }

        allVehicles->ExceptWith(someVehicles);
        Console::WriteLine("\nThe excepted HashSet contains:\n");
        for each (String^ vehicle in allVehicles)
        {
            Console::WriteLine(vehicle);
        }

        // Remove all the vehicles that are not 'super cool'.
        allVehicles->RemoveWhere(gcnew Predicate<String^>(&isNotSuperCool));

        Console::WriteLine("\nThe super cool vehicles are:\n");
        for each (String^ vehicle in allVehicles)
        {
            Console::WriteLine(vehicle);
        }
    }

private:
    // Predicate to determine vehicle 'coolness'.
    static bool isNotSuperCool(String^ vehicle)
    {
        bool superCool = (vehicle == "Helicopters") || (vehicle == "Motorcycles");

        return !superCool;
    }
};

int main()
{
    Program::Main();
}

// The program writes the following output to the console::
//
// The current HashSet contains:
//
// Planes
// Trains
// Automobiles
//
// The updated HashSet contains:
//
// Planes
// Trains
// Automobiles
// Ships
// Motorcycles
// Rockets
// Helicopters
// Submarines
//
// The 'All' vehicles set contains everything in 'Some' vechicles list.
//
// The 'All' vehicles set contains 'roCKeTs'
//
// The excepted HashSet contains:
//
// Ships
// Motorcycles
// Rockets
// Helicopters
// Submarines
//
// The super cool vehicles are:
//
// Motorcycles
// Helicopters
HashSet<string> allVehicles = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
List<string> someVehicles = new List<string>();

someVehicles.Add("Planes");
someVehicles.Add("Trains");
someVehicles.Add("Automobiles");

// Add in the vehicles contained in the someVehicles list.
allVehicles.UnionWith(someVehicles);

Console.WriteLine("The current HashSet contains:\n");
foreach (string vehicle in allVehicles)
{
    Console.WriteLine(vehicle);
}

allVehicles.Add("Ships");
allVehicles.Add("Motorcycles");
allVehicles.Add("Rockets");
allVehicles.Add("Helicopters");
allVehicles.Add("Submarines");

Console.WriteLine("\nThe updated HashSet contains:\n");
foreach (string vehicle in allVehicles)
{
    Console.WriteLine(vehicle);
}

// Verify that the 'All Vehicles' set contains at least the vehicles in
// the 'Some Vehicles' list.
if (allVehicles.IsSupersetOf(someVehicles))
{
    Console.Write("\nThe 'All' vehicles set contains everything in ");
    Console.WriteLine("'Some' vechicles list.");
}

// Check for Rockets. Here the OrdinalIgnoreCase comparer will compare
// true for the mixed-case vehicle type.
if (allVehicles.Contains("roCKeTs"))
{
    Console.WriteLine("\nThe 'All' vehicles set contains 'roCKeTs'");
}

allVehicles.ExceptWith(someVehicles);
Console.WriteLine("\nThe excepted HashSet contains:\n");
foreach (string vehicle in allVehicles)
{
    Console.WriteLine(vehicle);
}

// Remove all the vehicles that are not 'super cool'.
allVehicles.RemoveWhere(isNotSuperCool);

Console.WriteLine("\nThe super cool vehicles are:\n");
foreach (string vehicle in allVehicles)
{
    Console.WriteLine(vehicle);
}

// Predicate to determine vehicle 'coolness'.
bool isNotSuperCool(string vehicle)
{
    bool superCool = (vehicle == "Helicopters") || (vehicle == "Motorcycles");

    return !superCool;
}

// The program writes the following output to the console.
//
// The current HashSet contains:
//
// Planes
// Trains
// Automobiles
//
// The updated HashSet contains:
//
// Planes
// Trains
// Automobiles
// Ships
// Motorcycles
// Rockets
// Helicopters
// Submarines
//
// The 'All' vehicles set contains everything in 'Some' vechicles list.
//
// The 'All' vehicles set contains 'roCKeTs'
//
// The excepted HashSet contains:
//
// Ships
// Motorcycles
// Rockets
// Helicopters
// Submarines
//
// The super cool vehicles are:
//
// Motorcycles
// Helicopters
Imports System.Collections.Generic

Class Program
    Public Shared Sub Main()
        Dim allVehicles As New HashSet(Of String)(StringComparer.OrdinalIgnoreCase)
        Dim someVehicles As New List(Of String)()

        someVehicles.Add("Planes")
        someVehicles.Add("Trains")
        someVehicles.Add("Automobiles")

        ' Add in the vehicles contained in the someVehicles list.
        allVehicles.UnionWith(someVehicles)

        Console.WriteLine("The current HashSet contains:" + vbNewLine)
        For Each vehicle As String In allVehicles
            Console.WriteLine(vehicle)
        Next vehicle

        allVehicles.Add("Ships")
        allVehicles.Add("Motorcycles")
        allVehicles.Add("Rockets")
        allVehicles.Add("Helicopters")
        allVehicles.Add("Submarines")

        Console.WriteLine(vbNewLine + "The updated HashSet contains:" + vbNewLine)
        For Each vehicle As String In allVehicles
            Console.WriteLine(vehicle)
        Next vehicle

        ' Verify that the 'All Vehicles' set contains at least the vehicles in
        ' the 'Some Vehicles' list.
        If allVehicles.IsSupersetOf(someVehicles) Then
            Console.Write(vbNewLine + "The 'All' vehicles set contains everything in ")
            Console.WriteLine("'Some' vechicles list.")
        End If

        ' Check for Rockets. Here the OrdinalIgnoreCase comparer will compare
        ' True for the mixed-case vehicle type.
        If allVehicles.Contains("roCKeTs") Then
            Console.WriteLine(vbNewLine + "The 'All' vehicles set contains 'roCKeTs'")
        End If

        allVehicles.ExceptWith(someVehicles)
        Console.WriteLine(vbNewLine + "The excepted HashSet contains:" + vbNewLine)
        For Each vehicle As String In allVehicles
            Console.WriteLine(vehicle)
        Next vehicle

        ' Remove all the vehicles that are not 'super cool'.
        allVehicles.RemoveWhere(AddressOf isNotSuperCool)

        Console.WriteLine(vbNewLine + "The super cool vehicles are:" + vbNewLine)
        For Each vehicle As String In allVehicles
            Console.WriteLine(vehicle)
        Next vehicle
    End Sub

    ' Predicate to determine vehicle 'coolness'.
    Private Shared Function isNotSuperCool(vehicle As String) As Boolean
        Dim notSuperCool As Boolean = _
            (vehicle <> "Helicopters") And (vehicle <> "Motorcycles")

        Return notSuperCool
    End Function
End Class

'
' The program writes the following output to the console.
'
' The current HashSet contains:
'
' Planes
' Trains
' Automobiles
'
' The updated HashSet contains:
'
' Planes
' Trains
' Automobiles
' Ships
' Motorcycles
' Rockets
' Helicopters
' Submarines
'
' The 'All' vehicles set contains everything in 'Some' vechicles list.
'
' The 'All' vehicles set contains 'roCKeTs'
'
' The excepted HashSet contains:
'
' Ships
' Motorcycles
' Rockets
' Helicopters
' Submarines
'
' The super cool vehicles are:
'
' Motorcycles
' Helicopters

Comentarios

La capacidad de un objeto HashSet<T> es el número de elementos que puede contener el objeto.The capacity of a HashSet<T> object is the number of elements that the object can hold. La capacidad de un objeto HashSet<T> aumenta automáticamente a medida que se agregan elementos al objeto.A HashSet<T> object's capacity automatically increases as elements are added to the object.

Si collection contiene duplicados, el conjunto contendrá uno de cada elemento único.If collection contains duplicates, the set will contain one of each unique element. No se producirá ninguna excepción.No exception will be thrown. Por lo tanto, el tamaño del conjunto resultante no es idéntico al tamaño de collection.Therefore, the size of the resulting set is not identical to the size of collection.

Este constructor es una operación O (n), donde n es el número de elementos del parámetro collection.This constructor is an O(n) operation, where n is the number of elements in the collection parameter.

HashSet<T>(Int32, IEqualityComparer<T>)

Inicializa una nueva instancia de la clase HashSet<T> que usa el comparador de igualdad especificado para el tipo de conjunto y que tiene capacidad suficiente para alojar elementos capacity.Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, and has sufficient capacity to accommodate capacity elements.

public:
 HashSet(int capacity, System::Collections::Generic::IEqualityComparer<T> ^ comparer);
public HashSet (int capacity, System.Collections.Generic.IEqualityComparer<T> comparer);
new System.Collections.Generic.HashSet<'T> : int * System.Collections.Generic.IEqualityComparer<'T> -> System.Collections.Generic.HashSet<'T>
Public Sub New (capacity As Integer, comparer As IEqualityComparer(Of T))

Parámetros

capacity
Int32

Tamaño inicial de HashSet<T>.The initial size of the HashSet<T>

comparer
IEqualityComparer<T>

Implementación de IEqualityComparer<T> que se va a usar para comparar valores del conjunto, o bien Null (Nothing en Visual Basic) para usar la implementación predeterminada de IEqualityComparer<T> para el tipo de conjunto.The IEqualityComparer<T> implementation to use when comparing values in the set, or null (Nothing in Visual Basic) to use the default IEqualityComparer<T> implementation for the set type.

Comentarios

Dado que los redimensionamientos son relativamente caros (requieren un rehash), intenta minimizar la necesidad de cambiar el tamaño estableciendo la capacidad inicial según el valor de la capacity.Since resizes are relatively expensive (require rehashing), this attempts to minimize the need to resize by setting the initial capacity based on the value of the capacity.

HashSet<T>(SerializationInfo, StreamingContext)

Inicializa una nueva instancia de la clase HashSet<T> con datos serializados.Initializes a new instance of the HashSet<T> class with serialized data.

protected:
 HashSet(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected HashSet (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Collections.Generic.HashSet<'T> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.HashSet<'T>
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parámetros

info
SerializationInfo

Objeto SerializationInfo que contiene información necesaria para serializar el objeto HashSet<T>.A SerializationInfo object that contains the information required to serialize the HashSet<T> object.

context
StreamingContext

Estructura StreamingContext que contiene el origen y el destino del flujo serializado asociado al objeto HashSet<T>.A StreamingContext structure that contains the source and destination of the serialized stream associated with the HashSet<T> object.

Comentarios

Se llama a este constructor durante la deserialización para reconstituir un objeto que se transmite a través de una secuencia.This constructor is called during deserialization to reconstitute an object that is transmitted over a stream. Para obtener más información, consulte serialización SOAP y XML.For more information, see XML and SOAP Serialization.

Se aplica a