Export (0) Print
Expand All
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.

For a list of all members of this type, see PropertyCollection Members.

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

[Visual Basic]
Public Class PropertyCollection
   Inherits Hashtable
[C#]
public class PropertyCollection : Hashtable
[C++]
public __gc class PropertyCollection : public Hashtable
[JScript]
public class PropertyCollection extends Hashtable

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.

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.

Example

[Visual Basic, C#, C++] The following example creates a timestamp value for a DataTable and adds it to the PropertyCollection.

[Visual Basic] 
Private Sub AddTimeStamp()
    Dim p As PropertyCollection
    'Create a new DataTable.
    Dim dt As New DataTable("myNewTable")
    'Get its PropertyCollection.
    p = dt.ExtendedProperties
    'Add a timestamp value to the PropertyCollection.
    p.Add("myTimeStamp", DateTime.Now)
    'Print the timestamp.
    Console.WriteLine(p("myTimeStamp"))
End Sub 'AddTimeStamp

[C#] 
private void AddTimeStamp(){
    PropertyCollection p;
    //Create a new DataTable.
    DataTable dt = new DataTable("myNewTable");
    //Get its PropertyCollection.
    p = dt.ExtendedProperties;
    //Add a timestamp value to the PropertyCollection.
    p.Add("myTimeStamp", DateTime.Now);
    // Print the timestamp.
    Console.WriteLine(p["myTimeStamp"]);
 }

[C++] 
private:
void AddTimeStamp(){
    PropertyCollection* p;
    //Create a new DataTable.
    DataTable* dt = new DataTable(S"myNewTable");
    //Get its PropertyCollection.
    p = dt->ExtendedProperties;
    //Add a timestamp value to the PropertyCollection.
    p->Add(S"myTimeStamp",__box(DateTime::Now));
    // Print the timestamp.
    Console::WriteLine(p->Item[S"myTimeStamp"]);
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Data (in System.Data.dll)

See Also

PropertyCollection Members | System.Data Namespace | DataColumn | DataSet | DataTable | DataColumn.ExtendedProperties | DataSet.ExtendedProperties | DataTable.ExtendedProperties

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.