In general queries we take input sequence of items and generated output sequence as per given condition for example we have the list of various department employees and we want to take information only those employess who are belong to IT department . In that condition we can use restriction operator “where” in LINQ.
Let me demonstrate it with an simple example
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LINQExample { class Program { static void Main(string[] args) { employeedetails[] emp = { new employeedetails{ employeename="Ganesha", department="IT"}, new employeedetails{ employeename="Yogesh", department="IT"}, new employeedetails{ employeename="Ashish", department="Sales"}, new employeedetails{ employeename="Pooja", department="Teaching"}, new employeedetails{ employeename="Arti", department="Teaching"}, }; IEnumerable<employeedetails> empofIT = emp.Where(d => d.department == "IT"); foreach(employeedetails empdetail in empofIT ) { Console.WriteLine(empdetail.employeename + " " + empdetail.department); } Console.ReadLine(); } } public class employeedetails { public string employeename; public string department; } }