开发者

Seeing named datacolumns in Visual Studio debugger?

开发者 https://www.devze.com 2022-12-14 19:10 出处:网络
When I\'m debugging a datatable, say in th开发者_如何学运维e watch window, I\'ll often choose the Rows property, and then a particular index-- 0 or 1, often times.

When I'm debugging a datatable, say in th开发者_如何学运维e watch window, I'll often choose the Rows property, and then a particular index-- 0 or 1, often times.

When I do that, I see an ItemArray list with numeric indexing, representing the columns for the row. But the columns have names, and I'd like to see them. So instead of

myTable.Rows[0][6]

...where I'm guessing/pretty-but-not-quite sure the LastName column is in that location, I'd prefer to see the ItemArray list with the column names between the [] brackets, so I know for sure. Is there a property here I'm not seeing or is there a way to do it?


myTable.Rows[0]["columnName"] isn't work for you?

If you want to get a list of "columnName-value" you can use some kind of debug-helper:

class DebugHelper {
    public static Dictionary<string, object> GetValues(DataTable table, int rowId) {
        Dictionary<string, object> result = new Dictionary<string,object>();
        foreach(DataColumn column in table.Columns)
            result.Add(column.Caption, table.Rows[rowId][column]);
        return result;
    }
}

In watch, use DebugHelper.GetValues(table, 0)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号