Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataTable.ToString Method

Gets the TableName and DisplayExpression, if there is one as a concatenated string.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

Return Value

A string consisting of the TableName and the DisplayExpression values.

Remarks

Gets the TableName and DisplayExpression for the DataTable.

Example

[Visual Basic, C#, C++] The following example returns the TableName and DisplayExpression using the ToString method.

[Visual Basic] 
Private Sub PrintToString(ds As DataSet)
   Dim myTable As DataTable
   For Each myTable In ds.Tables
      Console.WriteLine(myTable.ToString())
   Next
End Sub

[C#] 
private void PrintToString(DataSet ds){
   foreach(DataTable myTable in ds.Tables){
      Console.WriteLine(myTable.ToString());
   }
}

[C++] 
private:
 void PrintToString(DataSet* ds){
    System::Collections::IEnumerator* myEnum = ds->Tables->GetEnumerator();
    while (myEnum->MoveNext())
    {
       DataTable* myTable = __try_cast<DataTable*>(myEnum->Current);
       Console::WriteLine(myTable->ToString());
    }
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataTable Class | DataTable Members | System.Data Namespace | DisplayExpression | TableName

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft