我需要为课程列表网站构建一个面包屑/路径
例如课程有不同的菜单项,我需要显示如下
- 第01章/
- Chapter01/Lesson01/
- Chapter01/Lesson01/Exam01/
- Chapter01/Lesson01/Exam01/问题03/
- Chapter01/Lesson01/Exam01/问题04/项目01
- Chapter01/Lesson02/
- 第02章
- Chapter02/Lesson01
以上只是项目如何排列在路径中的示例
为了想出这个我有物品清单
Public Class Item
{
public string Level
{
get;
set;
}
public string Title
{
get;
set;
}
}
该列表可以创建如下
IList<Item> Items = new List<Item>();
Items.Add (new Item {Level = "0", Title = "Chapter01"});
Items.Add (new Item {Level = "1", Title = "Lesson01"});
Items.Add (new Item {Level = "2", Title = "Exam01"});
Items.Add (new Item {Level = "3", Title = "Question 03"});
Items.Add (new Item {Level = "3", Title = "Question 04"});
Items.Add (new Item {Level = "4", Title = "Item 01"});
Items.Add (new Item {Level = "1", Title = "Lesson02"});
Items.Add (new Item {Level = "0", Title = "Chapter02"});
Items.Add (new Item {Level = "1", Title = "Lesson01"});
父项的级别始终为 0,子项的级别为 1、2、3 等...
任何人都可以指导我在 C# 中提出一个递归函数来实现这一点