This topic has not yet been rated - Rate this topic

PropertyCollection Class

Represents a collection of properties that can be added to DataColumn, DataSet, or DataTable.

System.Object
  System.Collections.Hashtable
    System.Data.PropertyCollection

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
[SerializableAttribute]
public class PropertyCollection : Hashtable

The PropertyCollection type exposes the following members.

  Name Description
Public method Supported by the XNA Framework PropertyCollection() Initializes a new instance of the PropertyCollection class.
Protected method PropertyCollection(SerializationInfo, StreamingContext) Initializes a new instance of the PropertyCollection class.
Top
  Name Description
Protected property Supported by the XNA Framework comparer Obsolete. Gets or sets the IComparer to use for the Hashtable. (Inherited from Hashtable.)
Public property Supported by the XNA Framework Count Gets the number of key/value pairs contained in the Hashtable. (Inherited from Hashtable.)
Protected property Supported by the XNA Framework EqualityComparer Gets the IEqualityComparer to use for the Hashtable. (Inherited from Hashtable.)
Protected property Supported by the XNA Framework hcp Obsolete. Gets or sets the object that can dispense hash codes. (Inherited from Hashtable.)
Public property Supported by the XNA Framework IsFixedSize Gets a value indicating whether the Hashtable has a fixed size. (Inherited from Hashtable.)
Public property Supported by the XNA Framework IsReadOnly Gets a value indicating whether the Hashtable is read-only. (Inherited from Hashtable.)
Public property Supported by the XNA Framework IsSynchronized Gets a value indicating whether access to the Hashtable is synchronized (thread safe). (Inherited from Hashtable.)
Public property Supported by the XNA Framework Item Gets or sets the value associated with the specified key. (Inherited from Hashtable.)
Public property Supported by the XNA Framework Keys Gets an ICollection containing the keys in the Hashtable. (Inherited from Hashtable.)
Public property Supported by the XNA Framework SyncRoot Gets an object that can be used to synchronize access to the Hashtable. (Inherited from Hashtable.)
Public property Supported by the XNA Framework Values Gets an ICollection containing the values in the Hashtable. (Inherited from Hashtable.)
Top
  Name Description
Public method Supported by the XNA Framework Add Adds an element with the specified key and value into the Hashtable. (Inherited from Hashtable.)
Public method Supported by the XNA Framework Clear Removes all elements from the Hashtable. (Inherited from Hashtable.)
Public method Supported by the XNA Framework Clone Creates a shallow copy of the Hashtable. (Inherited from Hashtable.)
Public method Supported by the XNA Framework Contains Determines whether the Hashtable contains a specific key. (Inherited from Hashtable.)
Public method Supported by the XNA Framework ContainsKey Determines whether the Hashtable contains a specific key. (Inherited from Hashtable.)
Public method Supported by the XNA Framework ContainsValue Determines whether the Hashtable contains a specific value. (Inherited from Hashtable.)
Public method Supported by the XNA Framework CopyTo Copies the Hashtable elements to a one-dimensional Array instance at the specified index. (Inherited from Hashtable.)
Public method Supported by the XNA Framework Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Supported by the XNA Framework Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the XNA Framework GetEnumerator Returns an IDictionaryEnumerator that iterates through the Hashtable. (Inherited from Hashtable.)
Protected method Supported by the XNA Framework GetHash Returns the hash code for the specified key. (Inherited from Hashtable.)
Public method Supported by the XNA Framework GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetObjectData Implements the ISerializable interface and returns the data needed to serialize the Hashtable. (Inherited from Hashtable.)
Public method Supported by the XNA Framework GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method Supported by the XNA Framework KeyEquals Compares a specific Object with a specific key in the Hashtable. (Inherited from Hashtable.)
Protected method Supported by the XNA Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method OnDeserialization Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. (Inherited from Hashtable.)
Public method Supported by the XNA Framework Remove Removes the element with the specified key from the Hashtable. (Inherited from Hashtable.)
Public method Supported by the XNA Framework ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Explicit interface implemetation Private method Supported by the XNA Framework IEnumerable.GetEnumerator Returns an enumerator that iterates through a collection. (Inherited from Hashtable.)
Top

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.

The following example creates a timestamp value for a DataTable and adds it to the PropertyCollection.


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"]);
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), 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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ