Filtered: prints the name of each element of an integer array that is less than 5 : where « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {

        int[] numbers = { 5, 4, 1, 3};
        string[] digits = { "zero", "one", "two", "three"};

        var lowNums =
            from n in numbers
            where n < 5
            select digits[n];

        Console.WriteLine("Numbers < 5:");
        foreach (var num in lowNums) {
            Console.WriteLine(num);
        }
    }
}








22.9.where
22.9.1.Where Prototype
22.9.2.To remove all vowels from a string.
22.9.3.A Query Using the Standard Dot Notation Syntax
22.9.4.Query Using the Query Expression Syntax
22.9.5.Query string value by String.StartsWith
22.9.6.Where clause with string method and return IEnumerable object
22.9.7.Query with an Exception
22.9.8.Use string method in where clause
22.9.9.where clause
22.9.10.Use where to filer object list
22.9.11.Use && in where clause
22.9.12.Filtered: prints the name of each element of an integer array that is less than 5
22.9.13.prints strings where each element has the second letter 'i'.
22.9.14.Two where clauses
22.9.15.Using where clause in a while loop
22.9.16.Assign the loop variable to another variable declared inside the statement block
22.9.17.Filter string by its length
22.9.18.Display Products With Unknown Price
22.9.19.Get upper case chars
22.9.20.Query by string length with Linq
22.9.21.Query for filtering numbers
22.9.22.Filter by Make and Speed
22.9.23.LINQ Method Syntax
22.9.24.Simple method based query
22.9.25.Search Customers by first name
22.9.26.LINQ query to get strings starting with s
22.9.27.Ice Creams with price less than 10
22.9.28.Use function in where clause
22.9.29.Modifying Where Behavior