递归方法 :

decimal Salary(Employee e)
  {
   
decimal s = e.salary;
   
if (e.EmployeeCollection !=null)
    {
     
foreach (Employee x in e.EmployeeCollection)
      {
        s
+= Salary(x);
      }
    }
   
return s;
  }

 

 

posted on 2012-07-20 14:59  热爱工作  阅读(123)  评论(0)    收藏  举报