DataRowCollectionとは? わかりやすく解説

DataRowCollection クラス

DataTable の行のコレクションを表します。

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public NotInheritable Class
 DataRowCollection
    Inherits InternalDataCollectionBase
Dim instance As DataRowCollection
public sealed class DataRowCollection : InternalDataCollectionBase
public ref class DataRowCollection sealed :
 public InternalDataCollectionBase
public final class DataRowCollection extends
 InternalDataCollectionBase
public final class DataRowCollection extends
 InternalDataCollectionBase
解説解説

DataRowCollection は DataTable の主要コンポーネントです。DataColumnCollection がテーブルのスキーマを定義するのに対して、DataRowCollection はテーブルの実際のデータを格納します。DataRowCollection に格納された各 DataRow は単一行を表します。

DataRowCollection に DataRow オブジェクトを挿入するには Add メソッドを呼び出し、オブジェクトを削除するには Remove メソッドを呼び出します。主キー列内の特定の値を格納する DataRow オブジェクトを検索するには Find メソッドを呼び出し、文字ベースのデータ内にある単一の単語または語句を検索するには Contains メソッドを呼び出します。

使用例使用例

このセクションの最初の例では、DataRowCollection 内の各行の列 1 の値を出力します。2 番目の例では、NewRow メソッドを使用して作成した新しい行を DataRowCollection に追加します。

Private Sub ShowRows(Byval
 table As DataTable)
    ' Print the number of rows in the collection.
    Console.WriteLine(table.Rows.Count)

    Dim row  As DataRow
    ' Print the value of columns 1 in each row
    For Each row In table.Rows
        Console.WriteLine(row(1))
    Next
End Sub
 
Private Sub AddRow(ByVal
 table As DataTable)
    ' Instantiate a new row using the NewRow method.
    Dim newRow As DataRow = table.NewRow()
    ' Insert code to fill the row with values.

    ' Add the row to the DataRowCollection.
    table.Rows.Add(newRow)
End Sub
private void ShowRows(DataTable table)
{
    // Print the number of rows in the collection.
    Console.WriteLine(table.Rows.Count);
    // Print the value of columns 1 in each row
    foreach(DataRow row in table.Rows)
    {
        Console.WriteLine(row[1]);
    }
}
 
private void AddRow(DataTable table)
{
    DataRowCollection rowCollection = table.Rows;
    // Instantiate a new row using the NewRow method.

    DataRow newRow = table.NewRow();
    // Insert code to fill the row with values.

    // Add the row to the DataRowCollection.
    table.Rows.Add(newRow);
}
継承階層継承階層
System.Object
   System.Data.InternalDataCollectionBase
    System.Data.DataRowCollection
スレッド セーフスレッド セーフ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataRowCollection メンバ
System.Data 名前空間
DataRow クラス
DataTable
NewRow

DataRowCollection プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ Count オーバーライドされます。 このコレクション内の DataRow オブジェクトの合計数を取得します。
パブリック プロパティ IsReadOnly  InternalDataCollectionBase が読み取り専用かどうかを示す値を取得します。 ( InternalDataCollectionBase から継承されます。)
パブリック プロパティ IsSynchronized  InternalDataCollectionBase の同期がとられているかどうかを示す値を取得します。 ( InternalDataCollectionBase から継承されます。)
パブリック プロパティ SyncRoot  コレクションの同期をとるために使用できるオブジェクトを取得します。 ( InternalDataCollectionBase から継承されます。)
プロテクト プロパティプロテクト プロパティ
参照参照

関連項目

DataRowCollection クラス
System.Data 名前空間
DataRow クラス
DataTable
NewRow

DataRowCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Add オーバーロードされます。 DataRow を DataRowCollection に追加します。
パブリック メソッド Clear すべての行のコレクションを消去します。
パブリック メソッド Contains オーバーロードされます。 このコレクション内のいずれかの行の主キー列に指定した値が格納されているかどうかを示す値を取得します。
パブリック メソッド CopyTo オーバーロードされます。 オーバーライドされます。 このコレクション内のすべての DataRow オブジェクトを、指定したコピー先配列インデックスから始まる指定した配列にコピーします。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Find オーバーロードされます。 指定した DataRow を取得します。
パブリック メソッド GetEnumerator オーバーライドされます。 このコレクションの IEnumerator を取得します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IndexOf 指定した DataRow オブジェクトのインデックスを取得します。
パブリック メソッド InsertAt コレクション内の指定した位置に新しい行を挿入します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定した DataRow をコレクションから削除します。
パブリック メソッド RemoveAt 指定したインデックス位置にある行をコレクションから削除します。
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataRowCollection クラス
System.Data 名前空間
DataRow クラス
DataTable
NewRow

DataRowCollection メンバ

DataTable の行のコレクションを表します。

DataRowCollection データ型で公開されるメンバを以下の表に示します。


パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ Count オーバーライドされます。 このコレクション内の DataRow オブジェクトの合計数を取得します。
パブリック プロパティ IsReadOnly  InternalDataCollectionBase が読み取り専用かどうかを示す値を取得します。(InternalDataCollectionBase から継承されます。)
パブリック プロパティ IsSynchronized  InternalDataCollectionBase の同期がとられているかどうかを示す値を取得します。(InternalDataCollectionBase から継承されます。)
パブリック プロパティ SyncRoot  コレクションの同期をとるために使用できるオブジェクトを取得します。(InternalDataCollectionBase から継承されます。)
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Add オーバーロードされます。 DataRow を DataRowCollection に追加します。
パブリック メソッド Clear すべての行のコレクションを消去します。
パブリック メソッド Contains オーバーロードされます。 このコレクション内のいずれかの行の主キー列に指定した値が格納されているかどうかを示す値を取得します。
パブリック メソッド CopyTo オーバーロードされます。 オーバーライドされます。 このコレクション内のすべての DataRow オブジェクトを、指定したコピー先配列インデックスから始まる指定した配列にコピーします。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド Find オーバーロードされます。 指定した DataRow を取得します。
パブリック メソッド GetEnumerator オーバーライドされます。 このコレクションの IEnumerator を取得します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IndexOf 指定した DataRow オブジェクトのインデックスを取得します。
パブリック メソッド InsertAt コレクション内の指定した位置に新しい行を挿入します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定した DataRow をコレクションから削除します。
パブリック メソッド RemoveAt 指定したインデックス位置にある行をコレクションから削除します。
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataRowCollection クラス
System.Data 名前空間
DataRow クラス
DataTable
NewRow


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataRowCollectionを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataRowCollectionを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataRowCollection を検索

英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DataRowCollection」の関連用語

DataRowCollectionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataRowCollectionのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS