DataTable.ExtendedProperties 属性

定义

获取自定义用户信息的集合。Gets the collection of customized user information.

public:
 property System::Data::PropertyCollection ^ ExtendedProperties { System::Data::PropertyCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("ExtendedPropertiesDescr")]
public System.Data.PropertyCollection ExtendedProperties { get; }
member this.ExtendedProperties : System.Data.PropertyCollection
Public ReadOnly Property ExtendedProperties As PropertyCollection

属性值

包含自定义用户信息的 PropertyCollectionA PropertyCollection that contains custom user information.

属性

示例

下面的示例通过 ExtendedProperties 属性向 DataTable 添加一个时间戳值。The following example adds a timestamp value to the DataTable through the ExtendedProperties property.

private void GetAndSetExtendedProperties(DataTable myTable){
   // Add an item to the collection.
   myTable.ExtendedProperties.Add("TimeStamp", DateTime.Now);
   // Print the item.
   Console.WriteLine(myTable.ExtendedProperties["TimeStamp"]);
}
Private Sub GetAndSetExtendedProperties(ByVal myTable As DataTable)
   ' Add an item to the collection.
   myTable.ExtendedProperties.Add("TimeStamp", DateTime.Now)
   ' Print the item.
   Console.WriteLine(myTable.ExtendedProperties.Item("TimeStamp"))
End Sub

注解

使用 ExtendedProperties 将自定义信息添加到 DataTableUse the ExtendedProperties to add custom information to a DataTable. Add 方法添加信息。Add information with the Add method. 检索 Item 方法的信息。Retrieve information with the Item method.

扩展属性的类型必须为 StringExtended properties must be of type String. 如果将 DataTable 编写为 XML,则不会持久保存类型不是字符串的属性。Properties that are not of type String are not persisted when the DataTable is written as XML.

适用于

另请参阅