次の方法で共有


PropertyCollection クラス

DataColumnDataSet 、または DataTable に追加できるプロパティのコレクションを表します。

この型のすべてのメンバの一覧については、PropertyCollection メンバ を参照してください。

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

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

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

PropertyCollection にアクセスするには、 DataColumnDataSet 、または DataTable の各クラスの ExtendedProperties プロパティを使用します。

PropertyCollection を使用して、 DataColumn オブジェクト、 DataSet オブジェクト、または DataTable オブジェクトにカスタム プロパティを追加します。たとえば、後で他のオブジェクトと比較するために、オブジェクトの作成時刻を格納できます。

使用例

[Visual Basic, C#, C++] DataTable のタイムスタンプ値を作成し、それを PropertyCollection に追加する例を次に示します。

 
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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Data

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

アセンブリ: System.Data (System.Data.dll 内)

参照

PropertyCollection メンバ | System.Data 名前空間 | DataColumn | DataSet | DataTable | DataColumn.ExtendedProperties | DataSet.ExtendedProperties | DataTable.ExtendedProperties