在“var response”中创建项目列表
我有以下代码:
var request = new GeocodingRequest();
request.Address = postcode;
request.Sensor = "false";
var response = GeocodingService.GetResponse(request);
var result = response.Results. ...?
我非常希望将结果作为列表,但我似乎无法转换它。我知道我可以做类似 response.Results.ToList
的事情,但没有运气。
任何人都可以帮忙吗:)
I have the following code:
var request = new GeocodingRequest();
request.Address = postcode;
request.Sensor = "false";
var response = GeocodingService.GetResponse(request);
var result = response.Results. ...?
I'd very much like to get result as a list, but I can't seem to convert it. I know I can do something like response.Results.ToList<string>();
, but have had no luck.
Can anyone help please :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么您可以只需使用:
或者
如果您想要一个字符串列表,您需要决定如何将每个结果转换为字符串。例如,您可以使用:
Well you can just use:
or
If you want a list of strings, you'll need to decide how you want to convert each result into a string. For example, you might use:
它的定义是:
如果你想让它列表调用:
response.Results.ToList()
。但为什么要把它列入清单呢?您可以将项目插入列表中,但我认为您不需要它。
It is defined as:
if you want to make it list call:
response.Results.ToList()
.But why do you want to make it list? You can insert items into list, but I don't think you need it.
假设response.Results是IEnumerable,只需确保System.Linq可用作命名空间并说response.Results.ToList()
assuming response.Results is IEnumerable, just make sure System.Linq is available as a namespace and say response.Results.ToList()