Query an array of object by its property value : Object Query « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
public class Book {
    public String Title { get; set; }

    public override String ToString() {
        return Title;
    }
}

class Program {
    static void Main(string[] args) {
        Book[] books = {
      new Book { Title="A" },
      new Book { Title="F" },
      new Book { Title="E" } };

        var titles =
          books
            .Where(book => book.Title.Contains("A"))
            .Select(book => book.Title);

    }
}








22.6.Object Query
22.6.1.Query an array of object by its property value
22.6.2.Select object in a List
22.6.3.Query by Person's FirstName
22.6.4.Query a list of objects by its property