List<Friend> lst = new List<Friend>();
Friend f1 = new Friend { FirstName = "Shantanu", LastName = "Kush" }; Friend f2 = new Friend { FirstName = "Vijay", LastName = "Kodwani" }; Friend f3 = new Friend { FirstName = "Naveed", LastName = "Ahmed" }; Friend f4 = new Friend { FirstName = "Parvez", LastName = "Naqati" };
lst.Add(f1); lst.Add(f2); lst.Add(f3); lst.Add(f4);
//This will execute a statement block against every second (step) friend in the list lst.For(0, lst.Count - 1, 2, (friend) => { MessageBox.Show(friend.FirstName); MessageBox.Show(friend.LastName); });
//This will execute a statement block against every second (step) friend in the list. //The End condition passed is also a lambda statement block lst.For(0, i => i < lst.Count - 1, 2, (friend) => { MessageBox.Show(friend.FirstName); MessageBox.Show(friend.LastName); });
|