英文:
How do I pass the KeyValuePair into this method?
问题
如何将KeyValuePair传递到这个方法中,接受ICollection<KeyValuePair<string, string>>
?
如果我的标头名称是'auth',标头值是'local'
_restActions.ExecutePostRequest(resource, body, {在这里放什么});
英文:
How do I pass the KeyValuePair into this method, accepting ICollection<KeyValuePair<string, string>>
?
If my header name is 'auth' and the header value is 'local'
_restActions.ExecutePostRequest(resource, body, {WHAT GOES HERE});
答案1
得分: 3
你可以传递一个实现了ICollection<KeyValuePair<string, string>>
的Dictionary<string, string>
,我认为这允许使用最简洁的实例化语法:
_restActions.ExecutePostRequest(
resource,
body,
new Dictionary<string, string>{{"one", "two"}, {"foo", "bar"}});
英文:
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"}});
答案2
得分: 1
由于headers
参数上有null
(默认值),所以您无需传递任何内容。
如果您确实想传递一些内容,那么可以是类似于new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("content-type", "text/plain") }
的任何内容。
英文:
You do not need to pass anything since there is null
on headers
parameter (default value).
If you do want to pass something then it would be anything like new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("content-type", "text/plain") }
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论