DataColumn.ToString DataColumn.ToString DataColumn.ToString DataColumn.ToString Method

定義

取得資料行的 Expression (如果存在)。Gets the Expression of the column, if one exists.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

如果屬性已經設定,則為 Expression 值,否則為 ColumnName 屬性。The Expression value, if the property is set; otherwise, the ColumnName property.

範例

下列範例會使用ToString屬性來傳回DataColumn物件集合中每個成員的預設字串。The following example uses the ToString property to return the default string of each member of a collection of DataColumn objects.

private void PrintColumns(DataTable table)
{
    // Print the default string of each column in a collection.
    foreach(DataColumn column in table.Columns)
    {
        Console.WriteLine(column.ToString());
    }
}
Private Sub PrintColumns(table As DataTable)
    ' Print the default string of each column in a collection.
    Dim column As DataColumn
    For Each column In table.Columns
       Console.WriteLine(column.ToString())
    Next
End Sub

適用於

另請參閱