Reputation: 918
I have a NameValueCollection with string keys and string values, like this:
fields["fieldname"] = "string value"
When I add a WATCH in VS20217 for "fields" it lets me expand a list of keys, but I don't seem to be able to get to the values unless I add an individual watch for each key.
I seem to recall doing this thing in the past but can't recall the method. Can anybody help?
Upvotes: 2
Views: 1260
Reputation: 3216
The low-friction approach would be to create an extension method first:
public static string DebugView(this NameValueCollection nvc)
{
return string.Join("\r\n", nvc.AllKeys.Select(key => $"{key}: {nvc[key]}"));
}
Then put nvc.DebugView()
as your watch variable, or capture that string to a variable and put a watch on that instead of the NameValueCollection
itself.
Upvotes: 1