What is the difference between SkipWhile() and Skip() methods in LINQ?
Skip() | SkipWhile() |
---|---|
Used to specify the amount (number) of items to skip in a LINQ expression. | Used to supply a predicate function on how many numbers to skip. |
It will take an integer argument and then simply skips those n numbers from the top of the given IEnumerable | It works on a per-line basis. It shall continue to skip if the value returned from the function is true. |
Syntax: yourlist.Skip(5) | Syntax: yourList.SkipWhile(x => x.marks < 50) |
BY Best Interview Question ON 02 Apr 2020