TakeWhile C# with Example
TakeWhile returns elements from a sequence as long as the condition is true int[] list = { 1, 10, 40, 50, 44, 70, 4 }; var result = list.TakeWhile(item => item < 50).ToList(); // result = { 1, 10, 40 }