Use Skip and SkipWhile with LINQ

Skip method : Skips items based on specified position starting From the first item in a sequence.
 
SkipWhile method : Is used to skip items based on specified condition until an item does not satisfy the condition. 
  1. IList<Customer> customerList = new List<Customer>()    
  2. {    
  3.     new Customer(){ CustomerId = 1, CustomerName = "James"},    
  4.     new Customer(){ CustomerId = 2, CustomerName = "Robert"},    
  5.     new Customer(){ CustomerId = 3, CustomerName = "Andres"},    
  6.     new Customer(){ CustomerId = 4, CustomerName = "Lionel"}    
  7. };    
  8.   
  9.   
  10. //Result (Skip) ==> Output : Andres, Lionel    
  11.   
  12. var ResultSkip = customerList.Skip(2);    
  13.   
  14. foreach (var item in ResultSkip)    
  15. {    
  16.     Console.WriteLine(item.CustomerName);    
  17. }    
  18.   
  19. Console.WriteLine("--------------------------");    
  20.   
  21. //Result (SkipWhile) ==> Output : Robert, Andres, Lionel    
  22. var ResultSkipWhile = customerList.SkipWhile(c => c.CustomerId < 2);    
  23.   
  24. foreach (var item in ResultSkipWhile)    
  25. {    
  26.     Console.WriteLine(item.CustomerName);    
  27. }    
  28. Console.ReadLine();