DataColumnCollection クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
DataTableのDataColumn オブジェクトのコレクションを表します。
public ref class DataColumnCollection sealed : System::Data::InternalDataCollectionBase
public ref class DataColumnCollection : System::Data::InternalDataCollectionBase
public sealed class DataColumnCollection : System.Data.InternalDataCollectionBase
[System.Serializable]
public class DataColumnCollection : System.Data.InternalDataCollectionBase
type DataColumnCollection = class
inherit InternalDataCollectionBase
[<System.Serializable>]
type DataColumnCollection = class
inherit InternalDataCollectionBase
Public NotInheritable Class DataColumnCollection
Inherits InternalDataCollectionBase
Public Class DataColumnCollection
Inherits InternalDataCollectionBase
- 継承
- 属性
例
次の例では、 DataColumn オブジェクトのコレクションを反復処理し、コレクション内の各列のさまざまなプロパティを出力します。
private void PrintDataTableColumnInfo(DataTable table)
{
// Use a DataTable object's DataColumnCollection.
DataColumnCollection columns = table.Columns;
// Print the ColumnName and DataType for each column.
foreach(DataColumn column in columns)
{
Console.WriteLine(column.ColumnName);
Console.WriteLine(column.DataType);
}
}
Private Sub PrintDataTableColumnInfo(table As DataTable)
' Use a DataTable object's DataColumnCollection.
Dim columns As DataColumnCollection = table.Columns
' Print the ColumnName and DataType for each column.
Dim column As DataColumn
For Each column in columns
Console.WriteLine(column.ColumnName)
Console.WriteLine(column.DataType.ToString)
Next
End Sub
注釈
DataColumnCollectionは、DataTableのスキーマを定義し、各DataColumnに含めることができるデータの種類を決定します。 DataTable オブジェクトの Columns プロパティを使用して、DataColumnCollectionにアクセスできます。
DataColumnCollectionでは、AddメソッドとRemoveメソッドを使用して、DataColumnオブジェクトを挿入および削除します。 Count プロパティを使用して、コレクション内のDataColumn オブジェクトの数を確認します。 Containsメソッドを使用して、指定したインデックスまたは列名がコレクション内に存在するかどうかを確認します。
プロパティ
| 名前 | 説明 |
|---|---|
| Count |
コレクション内の要素の合計数を取得します。 (継承元 InternalDataCollectionBase) |
| IsReadOnly |
InternalDataCollectionBaseが読み取り専用かどうかを示す値を取得します。 (継承元 InternalDataCollectionBase) |
| IsSynchronized |
InternalDataCollectionBaseが同期されているかどうかを示す値を取得します。 (継承元 InternalDataCollectionBase) |
| Item[Int32] |
指定したインデックス位置にあるコレクションから DataColumn を取得します。 |
| Item[String] |
指定した名前のコレクションから DataColumn を取得します。 |
| List |
コレクションの項目をリストとして取得します。 |
| List |
コレクションの項目をリストとして取得します。 (継承元 InternalDataCollectionBase) |
| SyncRoot |
コレクションの同期に使用できるオブジェクトを取得します。 (継承元 InternalDataCollectionBase) |
メソッド
イベント
| 名前 | 説明 |
|---|---|
| CollectionChanged |
列を追加または削除することによって、列コレクションが変更されたときに発生します。 |
拡張メソッド
| 名前 | 説明 |
|---|---|
| AsParallel(IEnumerable) |
クエリの並列化を有効にします。 |
| AsQueryable(IEnumerable) |
IEnumerable を IQueryableに変換します。 |
| Cast<TResult>(IEnumerable) |
IEnumerable の要素を指定した型にキャストします。 |
| OfType<TResult>(IEnumerable) |
指定した型に基づいて、IEnumerable の要素をフィルター処理します。 |
適用対象
スレッド セーフ
この型は、マルチスレッド読み取り操作に安全です。 すべての書き込み操作を同期する必要があります。