List<User> list = new List<User>()
            {
                new User{id=1 },
                new User{id=2 },
                new User{id=3 },
            };
            
            list.ForEach(p => Console.WriteLine(p.id));//等同于forearth
           //里面写判断
            list.ForEach(p =>
           {
               if (p.id==2)
               {
                   Console.WriteLine(p.id.ToString());
               }
           }            
            );
 public class User
    {
        public int id { get; set; }
        public string name { get; set; }
        public int parentId { get; set; }
    }

 

posted on 2019-10-31 15:50  红磨坊后的白桦树  阅读(278)  评论(0编辑  收藏  举报