日期:2014-05-17 浏览次数:20773 次
interface IClassHaveName { string Name { get; set; } } protected void InitDepartment<T>(T dept, TreeNode root) where T : IClassHaveName { T[] subDepartments = dept.GetEnabledSubDepartments(); foreach (T item in subDepartments) { TreeNode node = new TreeNode(item.Name, 1, 2); node.Tag = item; this.InitDepartment(item, node); root.Nodes.Add(node); } } class DAL.Department : IClassHaveName { ... }