//C# 函数方法内部实现循环调用自身 void TreeViewFresh(){ Action<TreeNodeCollection, MenuItem> addNode
= (TreeNodeCollection, MenuItem) => { }; addNode = (tn, mn) =>{ if (mn.Text != "-"){ tn.Add(mn.Text, mn.Text); if (mn.IsParent) foreach (MenuItem mnn in mn.MenuItems) addNode(tn[mn.Text].Nodes, mnn); } }; TreeView1.Nodes.Clear(); foreach (MenuItem mn in mainMenu1.MenuItems) addNode(TreeView1.Nodes, mn); }