Query an array of object by its property value
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);
}
}
Related examples in the same category