public void Calc1(int initCount, int avgCount, int endClass)
{
List<TreeData> list1 = new List<TreeData>();
TreeData data1 = new Models.TreeData() { id = 0, name = "推客", parentid = 0, value = 0 };
List<TreeData> list2 = new List<Models.TreeData>();
for (int b = 0; b < avgCount; b++)
{
TreeData data2 = new Models.TreeData() { id = 0, name = "推客", parentid = 0, value = 0 };
List<TreeData> list3 = new List<Models.TreeData>();
for (int c = 0; c < avgCount; c++)
{
TreeData data3 = new Models.TreeData() { id = 0, name = "推客", parentid = 0, value = 0 };
list3.Add(data3);
data2.children = list3;
}
list2.Add(data2);
data1.children = list2;
}
list1.Add(data1);
}
TreeData 结构如下
public class TreeData
{
public string name { get; set; }
public int? value { get; set; }
[JsonIgnore]
public int? id { get; set; }
[JsonIgnore]
public int? parentid { get; set; }
public List<TreeData> children { get; set; }
}
最终层级是endClass