Let us create a console application and see how it is done. Copy the following code in the Console application.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication3
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] cities =
- {
- "MUMBAI","NEW DELHI","AMSTERDAM","ZURICH","PARIS"
- };
- var _result = from x in cities
- where x.StartsWith("M")
- where x.EndsWith("I")
- select x;
- foreach(var city in _result)
- {
- Console.Write("CITY: {0}", city);
- }
- Console.ReadLine();
- }
- }
- }
Let us run the program to check whether our code is working fine or not.

Well, we got the desired output. In this way we can use multiple where clauses in a LINQ query.

Join the conversation! Your thoughts help the community grow.