【发布时间】:2015-02-24 10:22:49
【问题描述】:
我对 C# 还很陌生,但遇到了一个我无法弄清楚的错误?
我有一个要循环一系列节点的视图,所以我正在尝试这样做:
@foreach (var crumb in Model.Breadcrumb)
{
//My code
}
在我的视图模型中,我有这个:
public IEnumerable<LinkModel> Breadcrumb(IPublishedContent content) {
//Do logic.
return GetFrontpage(content, true).Reverse().Select(item => new LinkModel {
Target = "",
Text = item.Name,
Url = item.Url
});
}
private static IEnumerable<IPublishedContent> GetFrontpage(IPublishedContent content, bool includeFrontpage = false)
{
var path = new List<IPublishedContent>();
while (content.DocumentTypeAlias != "frontpage")
{
if (content == null)
{
throw new Exception("No frontpage found");
}
path.Add(content);
content = content.Parent;
}
if (includeFrontpage)
{
path.Add(content);
}
return path;
}
【问题讨论】:
-
编译错误指向哪一行?
标签: c# asp.net-mvc umbraco