在打印列名以及每个行值时,当前上下文中不存在行。?

Row does not exist in current context while printing the Column name along with each row value.?

我正在尝试打印数据表列名和值,但出现错误
行在当前上下文中不存在
我的代码 below.have 尝试了 How do I get column names to print in this C# program? 的解决方案但没有工作

foreach (DataRow row in dtfinal.Rows)
        {
            foreach (DataColumn col in dtfinal.Columns)

               Console.WriteLine(col.ColumnName);
            Console.WriteLine(row[col]); //error coming here

        }

Do that like this

foreach (DataRow row in dtfinal.Rows)
{
    foreach (DataColumn column in dtfinal.Columns)
    {
        Console.Write("Item: ");
        Console.Write(column.ColumnName);
        Console.Write(" ");
        Console.WriteLine(row[column]);
    }
}