DataColumnCollection Classe
Definição
Representa uma coleção de objetos DataColumn para um DataTable.Represents a collection of DataColumn objects for a DataTable.
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
- Herança
- Atributos
Exemplos
O exemplo a seguir itera em uma coleção de DataColumn objetos e imprime várias propriedades de cada coluna na coleção.The following example iterates through a collection of DataColumn objects and prints various properties of each column in the collection.
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
Comentários
O DataColumnCollection define o esquema de um DataTable e determina que tipo de dados cada um DataColumn pode conter.The DataColumnCollection defines the schema of a DataTable, and determines what kind of data each DataColumn can contain. Você pode acessar o DataColumnCollection por meio da Columns Propriedade do DataTable objeto.You can access the DataColumnCollection through the Columns property of the DataTable object.
O DataColumnCollection usa os Add Remove métodos e para inserir e excluir DataColumn objetos.The DataColumnCollection uses the Add and Remove methods to insert and delete DataColumn objects. Use a Count propriedade para determinar quantos DataColumn objetos estão na coleção.Use the Count property to determine how many DataColumn objects are in the collection. Use o Contains método para verificar se existe um índice ou nome de coluna especificado na coleção.Use the Contains method to verify whether a specified index or column name exists in the collection.
Propriedades
Count |
Obtém o número total de elementos em uma coleção.Gets the total number of elements in a collection. (Herdado de InternalDataCollectionBase) |
IsReadOnly |
Obtém um valor que indica se o InternalDataCollectionBase é somente leitura.Gets a value that indicates whether the InternalDataCollectionBase is read-only. (Herdado de InternalDataCollectionBase) |
IsSynchronized |
Obtém um valor que indica se o InternalDataCollectionBase é sincronizado.Gets a value that indicates whether the InternalDataCollectionBase is synchronized. (Herdado de InternalDataCollectionBase) |
Item[Int32] |
Obtém o DataColumn da coleção no índice especificado.Gets the DataColumn from the collection at the specified index. |
Item[String] |
Obtém o DataColumn da coleção com o nome especificado.Gets the DataColumn from the collection with the specified name. |
List |
Obtém os itens da coleção como uma lista.Gets the items of the collection as a list. |
List |
Obtém os itens da coleção como uma lista.Gets the items of the collection as a list. (Herdado de InternalDataCollectionBase) |
SyncRoot |
Obtém um objeto que pode ser usado para sincronizar a coleção.Gets an object that can be used to synchronize the collection. (Herdado de InternalDataCollectionBase) |
Métodos
Add() |
Cria e adiciona um objeto DataColumn ao DataColumnCollection.Creates and adds a DataColumn object to the DataColumnCollection. |
Add(DataColumn) |
Cria e adiciona o objeto especificado DataColumn ao DataColumnCollection.Creates and adds the specified DataColumn object to the DataColumnCollection. |
Add(String) |
Cria e adiciona um objeto DataColumn que tem o nome especificado ao DataColumnCollection.Creates and adds a DataColumn object that has the specified name to the DataColumnCollection. |
Add(String, Type) |
Cria e adiciona um objeto DataColumn que tem o nome e tipo especificado ao DataColumnCollection.Creates and adds a DataColumn object that has the specified name and type to the DataColumnCollection. |
Add(String, Type, String) |
Cria e adiciona um objeto DataColumn que tem o nome, tipo e expressão especificados ao DataColumnCollection.Creates and adds a DataColumn object that has the specified name, type, and expression to the DataColumnCollection. |
AddRange(DataColumn[]) |
Copia os elementos da matriz DataColumn especificada para o fim da coleção.Copies the elements of the specified DataColumn array to the end of the collection. |
CanRemove(DataColumn) |
Verifica se uma coluna específica pode ser removida da coleção.Checks whether a specific column can be removed from the collection. |
Clear() |
Limpa a coleção de todas as colunas.Clears the collection of any columns. |
Contains(String) |
Verifica se a coleção tem uma coluna com o nome especificado.Checks whether the collection contains a column with the specified name. |
CopyTo(Array, Int32) |
Copia todos os elementos do InternalDataCollectionBase atual para um Array unidimensional, começando no índice InternalDataCollectionBase especificado.Copies all the elements of the current InternalDataCollectionBase to a one-dimensional Array, starting at the specified InternalDataCollectionBase index. (Herdado de InternalDataCollectionBase) |
CopyTo(DataColumn[], Int32) |
Copia toda a coleção para uma matriz existente, iniciando em um índice especificado na matriz.Copies the entire collection into an existing array, starting at a specified index within the array. |
Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
GetEnumerator() |
Obtém um IEnumerator para a coleção.Gets an IEnumerator for the collection. (Herdado de InternalDataCollectionBase) |
GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
IndexOf(DataColumn) |
Obtém o índice de uma coluna especificada pelo nome.Gets the index of a column specified by name. |
IndexOf(String) |
Obtém o índice da coluna com o nome específico (o nome não diferencia maiúsculas de minúsculas).Gets the index of the column with the specific name (the name is not case sensitive). |
MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
OnCollectionChanged(CollectionChangeEventArgs) |
Aciona o evento OnCollectionChanged(CollectionChangeEventArgs).Raises the OnCollectionChanged(CollectionChangeEventArgs) event. |
OnCollectionChanging(CollectionChangeEventArgs) | |
Remove(DataColumn) |
Remove o objeto DataColumn especificado da coleção.Removes the specified DataColumn object from the collection. |
Remove(String) |
Remove da coleção o objeto DataColumn que tem o nome especificado.Removes the DataColumn object that has the specified name from the collection. |
RemoveAt(Int32) |
Remove a coluna no índice especificado da coleção.Removes the column at the specified index from the collection. |
ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |
Eventos
CollectionChanged |
Ocorre quando uma coleção de colunas é alterada, seja pela inclusão ou pela remoção de uma coluna.Occurs when the columns collection changes, either by adding or removing a column. |
Métodos de Extensão
Cast<TResult>(IEnumerable) |
Converte os elementos de um IEnumerable para o tipo especificado.Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filtra os elementos de um IEnumerable com base em um tipo especificado.Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Habilita a paralelização de uma consulta.Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Converte um IEnumerable em um IQueryable.Converts an IEnumerable to an IQueryable. |
Aplica-se a
Acesso thread-safe
Este tipo é seguro para operações de leitura e multithread.This type is safe for multithreaded read operations. Você deve sincronizar todas as operações de gravação.You must synchronize any write operations.