DataRowCollection.InsertAt(DataRow, Int32) 方法

定义

将新行插入到集合中的指定位置。Inserts a new row into the collection at the specified location.

public:
 void InsertAt(System::Data::DataRow ^ row, int pos);
public void InsertAt (System.Data.DataRow row, int pos);
member this.InsertAt : System.Data.DataRow * int -> unit
Public Sub InsertAt (row As DataRow, pos As Integer)

参数

row
DataRow

要添加的 DataRowThe DataRow to add.

pos
Int32

您要添加该 DataRow 的集合的位置(位置从零开始)。The (zero-based) location in the collection where you want to add the DataRow.

例外

pos 小于 0。The pos is less than 0.

注解

指定的位置 InsertAt 由中的行顺序反映 DataRowCollectionThe location specified by InsertAt is reflected by the order of rows in the DataRowCollection only. 如果数组中返回了多行 DataRow ,则插入的行可能不会在指定的位置返回 InsertAtIf more than one row is returned in a DataRow array, the inserted row may not be returned in the location specified by InsertAt. 例如, Rows 属性返回指定插入位置的行。For example, the Rows property returns the row in the specified insert position. SelectGetChildRows 可能不会。Select and GetChildRows may not. 例如,如果将的内容写入 DataRowCollection 为 XML,则 WriteXml 将根据指定的顺序写入行 DataRowCollectionWhen you write the contents of the DataRowCollection as XML, for example, WriteXml, the rows are written according to the order specified by the DataRowCollection.

如果为参数指定的值 pos 大于集合中的行数,则新行将添加到末尾。If the value specified for the pos parameter is greater than the number of rows in the collection, the new row is added to the end.

适用于