ArcGIS Explorer Component Help |
ColumnCollection..::.Count Property |
ColumnCollection Class Example See Also |
Gets the count of the number of columns in the Table.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
Field Value
The number of columns in the Table.Examples
The code below opens the Regions file geodatabase feature class and shows how to loop over all the columns
in the Table using two different approaches. The second example uses the Count property to determine
how many times to perform the loop.
CopyC#
//Open the regions feature class stored in the Scotland file geodatabase Geodatabase gdb = new Geodatabase(@"C:\Data\Scotland.gdb"); Table regionsTable = gdb.OpenTable("regions"); //return a collection containing all columns in the Regions table ColumnCollection columns = regionsTable.Columns; //Example 1 - use a for each loop to iterate over all columns in the Regions table foreach (Column col in columns) { //Print the name of each column System.Diagnostics.Debug.Print(col.Name); //Print the column type System.Diagnostics.Debug.Print(col.Type.ToString()); } //Example 2 - alternative approach - use a for/next loop to access each column by index position for (int i = 0; i < columns.Count; i++) { Column col = columns[i]; //Print the name of each column System.Diagnostics.Debug.Print(col.Name); //Print the column type System.Diagnostics.Debug.Print(col.Type.ToString()); }
CopyVB.NET
'Open regions feature class stored in the Scotland file geodatabase Dim gdb As Geodatabase = New Geodatabase("C:\Data\Scotland.gdb") Dim regionsTable As Table = gdb.OpenTable("regions") 'return a collection containing all columns in the Regions table Dim columns As ColumnCollection = regionsTable.Columns 'Example 1 - use a for each loop to iterate over all columns in the Regions table For Each col As Column In columns 'Print the name of each column System.Diagnostics.Debug.Print(col.Name) 'Print the column type System.Diagnostics.Debug.Print(col.Type.ToString()) Next 'Example 2 - alternative approach - use a for loop to access each column by index position For i As Integer = 0 To columns.Count - 1 Dim col As Column = columns.Item(i) 'Print the name of each column System.Diagnostics.Debug.Print(col.Name) 'Print the column type System.Diagnostics.Debug.Print(col.Type.ToString()) Next