Search code examples
c#key-valueicollection

How do I pass the KeyValuePair into this method?


How do I pass the KeyValuePair into this method, accepting ICollection<KeyValuePair<string, string>>?

enter image description here

If my header name is 'auth' and the header value is 'local'

_restActions.ExecutePostRequest(resource, body, {WHAT GOES HERE});

Solution

  • You can pass a Dictionary<string, string> which implements ICollection<KeyValuePair<string, string>> and, I would argue, allows the most concise instantiation syntax:

    _restActions.ExecutePostRequest(
        resource, 
        body, 
        new Dictionary<string, string>{{"one", "two"}, {"foo", "bar"}});