If you're looking for slightly less verbose syntax you can create a subclass of Dictionary<string, object>
(or whatever your type is) like this :
public class DebugKeyValueDict : Dictionary<string, object>
{
}
Then just initialize like this
var debugValues = new DebugKeyValueDict
{
{ "Billing Address", billingAddress },
{ "CC Last 4", card.GetLast4Digits() },
{ "Response.Success", updateResponse.Success }
});
Which is equivalent to
var debugValues = new Dictionary<string, object>
{
{ "Billing Address", billingAddress },
{ "CC Last 4", card.GetLast4Digits() },
{ "Response.Success", updateResponse.Success }
});
The benefit being you get all the compile type stuff you might want such as being able to say
is DebugKeyValueDict
instead of is IDictionary<string, object>
or changing the types of the key or value at a later date.
If you're doing something like this within a razor cshtml page it is a lot nicer to look at.
As well as being less verbose you can of course add extra methods to this class for whatever you might want.