若IEnumerable<T>作为方法返回值的类型,则建议使用“迭代”模式(yield return)
private IEnumerable<TwoLevelTreeNodeViewModel> CreatePFNode(IEnumerable<PoliceForceViewModel> pfvm)
{
foreach (var pf in pfvm)
{
yield return new TwoLevelTreeNodeViewModel()
{
HeaderText = pf.Text,
Tag = pf.RelativeData
};
}
}