The Select operator always returns an IEnumerable collection which contains elements based on a transformation function. It is similar to the Select clause of SQL that produces a flat result set.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Prototype{
class Example
{
static void Main()
{
IList<Employee> empList = new List<Employee>() {
new Employee() { ID = 1, EmpName = "Rohit", Age = 13 } ,
new Employee() { ID = 2, EmpName = "Monu", Age = 21 } ,
new Employee() { ID = 3, EmpName = "Mohsan", Age = 18 } ,
new Employee() { ID = 4, EmpName = "Sohel" , Age = 20 } ,
new Employee() { ID = 5, EmpName = "Arun" , Age = 20 } ,
new Employee() { ID = 6, EmpName = "Karan" , Age = 25 }
};
var selectResult = from s in empList
select new { Name = "Mr. " + s.EmpName, Age = s.Age };
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The Select operator always returns an IEnumerable collection which contains elements based on a transformation function. It is similar to the Select clause of SQL that produces a flat result set.