.NET Framework Class Library PropertyCollection Class

Inheritance Hierarchy
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
<SerializableAttribute> _
Public Class PropertyCollection _
Inherits Hashtable
[SerializableAttribute]
public class PropertyCollection : Hashtable
[SerializableAttribute]
public ref class PropertyCollection : public Hashtable
[<SerializableAttribute>]
type PropertyCollection =
class
inherit Hashtable
end
The PropertyCollection type exposes the following members.

Constructors

Properties

Methods

Explicit Interface Implementations

Remarks
The PropertyCollection can be accessed through the ExtendedProperties property of the DataColumn, DataSet, or DataTable class. Add custom properties to the DataColumn, DataSet, or DataTable objects through the PropertyCollection. For example, you may want to store the time of the object's creation for later comparison to another object.

Examples
The following example creates a timestamp value for a DataTable and adds it to the PropertyCollection.
Private Sub AddTimeStamp()
'Create a new DataTable.
Dim table As New DataTable("NewTable")
'Get its PropertyCollection.
Dim properties As PropertyCollection = table.ExtendedProperties
'Add a timestamp value to the PropertyCollection.
properties.Add("TimeStamp", DateTime.Now)
'Print the timestamp.
Console.WriteLine(properties("TimeStamp"))
End Sub
private void AddTimeStamp()
{
//Create a new DataTable.
DataTable table = new DataTable("NewTable");
//Get its PropertyCollection.
PropertyCollection properties = table.ExtendedProperties;
//Add a timestamp value to the PropertyCollection.
properties.Add("TimeStamp", DateTime.Now);
// Print the timestamp.
Console.WriteLine(properties["TimeStamp"]);
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
Biblioteca de clases de .NET Framework PropertyCollection (Clase)

Jerarquía de herencia
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
<SerializableAttribute> _
Public Class PropertyCollection _
Inherits Hashtable
[SerializableAttribute]
public class PropertyCollection : Hashtable
[SerializableAttribute]
public ref class PropertyCollection : public Hashtable
[<SerializableAttribute>]
type PropertyCollection =
class
inherit Hashtable
end
El tipo PropertyCollection expone los siguientes miembros.

Constructores

Propiedades

Métodos

Implementaciones explícitas de interfaces

Comentarios
Se puede obtener acceso a PropertyCollection mediante la propiedad ExtendedProperties de la clase DataColumn, DataSet o DataTable. Agrega propiedades personalizadas a los objetos DataColumn, DataSet o DataTable mediante PropertyCollection. Por ejemplo, es posible que desee almacenar la hora de creación del objeto para su posterior comparación con la de otro objeto.

Ejemplos
En el siguiente ejemplo se crea un valor de marca de hora para DataTable y se agrega a PropertyCollection.
Private Sub AddTimeStamp()
'Create a new DataTable.
Dim table As New DataTable("NewTable")
'Get its PropertyCollection.
Dim properties As PropertyCollection = table.ExtendedProperties
'Add a timestamp value to the PropertyCollection.
properties.Add("TimeStamp", DateTime.Now)
'Print the timestamp.
Console.WriteLine(properties("TimeStamp"))
End Sub
private void AddTimeStamp()
{
//Create a new DataTable.
DataTable table = new DataTable("NewTable");
//Get its PropertyCollection.
PropertyCollection properties = table.ExtendedProperties;
//Add a timestamp value to the PropertyCollection.
properties.Add("TimeStamp", DateTime.Now);
// Print the timestamp.
Console.WriteLine(properties["TimeStamp"]);
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Seguridad para subprocesos
Todos los miembros static ( Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Vea también
|