C# Code Snippets

Linq Objects

w3mentor.com

Platform: .NET Framework 3.5

List initialization:
List<Book> ListOfBooks = new List<Book>()
{
    new Book {name = "DaVinci Code"    , owner = "Alex" , date = 2002},
    new Book {name = "Angels and Demons", owner = "Jeff" , date = 2005},
    new Book {name = "The Last Mughal", owner = "Danny", date = 2001},
};

LINQ query:
IEnumerable<Book> QueryResult = from Book in ListOfBooks
                                select Book;

http://w3mentor.com/learn/asp-dot-net-c-sharp/c-asp-net-linq/linq-to-objects-query-objects-in-linq/

 

Back to C# Code Snippet List