Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

IEnumerable variables in LINQ Queries in C#

When you see a query variable that is typed as IEnumerable<Customer>, it just means that the query, when it is executed, will produce a sequence of zero or more Customer objects.

Example:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace ForgetCode
  7. {
  8. public class MainClass
  9. {
  10. public static void Main()
  11. {
  12. // Load your DB file here
  13. IEnumerable<Customer> customerQuery =
  14. from cust in customers
  15. where cust.City == "London"
  16. select cust;
  17.  
  18. foreach (Customer customer in customerQuery)
  19. {
  20. Console.WriteLine(customer.LastName + ", " + customer.FirstName);
  21. }
  22. }
  23. }
  24. }