【发布时间】:2014-11-03 19:39:51
【问题描述】:
我正在使用 mvc4 和 C#
我有模特
public class Prod {
private List<string> _photos;
public int Id { get; private set; }
public string Name { get; set; }
public IEnumerable<string> Photos {
get {
if (_photos == null) {
getPhotos();
}
return _photos;
}
private set{
_photos = value.ToList();
}
}
并将其放入控制器的列表中
List<Prod> products = new Products().ToList();
return View(products);
在照片中包含一个字符串,我尝试在查看页面中显示该字符串,
@model List<...Products.Prod>
@foreach (var pro in Model)
{
@pro.Photos;
}
我得到的值为 System.Collections.Generic.List`1[System.String]。如何获取对应的字符串。
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4