DataColumn.Ordinal DataColumn.Ordinal DataColumn.Ordinal DataColumn.Ordinal Property

定義

取得 DataColumnCollection 集合中 (以零起始) 的資料行位置。Gets the (zero-based) position of the column in the DataColumnCollection collection.

public:
 property int Ordinal { int get(); };
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataColumnOrdinalDescr")]
public int Ordinal { get; }
member this.Ordinal : int
Public ReadOnly Property Ordinal As Integer

屬性值

資料行的位置。The position of the column. 如果資料行不是集合的成員,則取得 -1。Gets -1 if the column is not a member of a collection.

範例

下列範例會傳回資料行的資料行名稱、序數和資料類型。The following example returns the column name, ordinal, and data type of a column.

private void PrintColumnDetails(DataColumn column)
{
    // Print the Ordinal, ColumnName, and 
    // DataType of the column.
    Console.WriteLine(column.Ordinal);
    Console.WriteLine(column.ColumnName);
    Console.WriteLine(column.DataType);
}
Private Sub PrintColumnDetails(ByVal column As DataColumn)
    ' Print the Ordinal, ColumnName, and 
    ' DataType of the column.
    Console.WriteLine(column.Ordinal)
    Console.WriteLine(column.ColumnName)
    Console.WriteLine(column.DataType)
End Sub

適用於

另請參閱