C# program to print the employees whose salary between 6000 and 8000 using LINQ
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to print employee details using LINQ in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created an Employee class that contains data members ID, Name, Age, and Salary. Here we override the ToString() method to return Employee information. The Employee class also one more method is known as Main().
In the Main() method, we created List collection for Employees, It contains information of 4 employees.
In the above code, we created a query to get a list of employees whose salary between 6000 and 8000. Then we printed the Employee detail using the "foreach" loop on the console screen.