Created
April 13, 2020 23:05
-
-
Save BlitzkriegSoftware/59e28d8c1f9d9809b53812949f2a4e02 to your computer and use it in GitHub Desktop.
Take a C# System.Data.DataTable and dump it to the console for debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void DumpDataTable(DataTable dt) | |
{ | |
if((dt == null) || (!SqlHelper.HasRows(dt))) | |
{ | |
Console.Error.WriteLine("There are no rows"); | |
} else | |
{ | |
foreach(DataColumn c in dt.Columns) | |
{ | |
Console.Write($"\"{c.ColumnName}\","); | |
} | |
Console.WriteLine(""); | |
foreach(DataRow dr in dt.Rows) | |
{ | |
for (int i = 0; i < dr.ItemArray.Length; i++) | |
{ | |
Console.Write($"\"{dr.ItemArray[i]}\","); | |
} | |
Console.WriteLine(""); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment