Filtering
Context: Filtering operators (Where, OfType) select elements that satisfy a condition.
int[] numbers = { 1, 2, 3, 4, 5 };var even = numbers.Where(n => n % 2 == 0); // 2,4
object[] mixed = { 1, "two", 3, "four" };var strings = mixed.OfType<string>(); // "two", "four"Real-world usage example
Section titled “Real-world usage example”Filtering invalid data: Use Where to exclude nulls, empty strings, or out‑of‑range values.
Example: In ASP.NET Core, you filter collections before sending to the view.