---
title: "How to use Select projection in LINQ?"  
description: "How to use Select projection in LINQ?"  
author: "Ethan Karla"  
published: 2021-09-24  
updated: 2021-09-24  
canonical: https://www.mindstick.com/forum/156758/how-to-use-select-projection-in-linq  
category: "linq"  
tags: ["c#", "ado.net", "linq"]  
reading_time: 4 minutes  

---

# How to use Select projection in LINQ?

How to use [Select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) projection in [LINQ](https://www.mindstick.com/articles/12007/language-integrated-query-linq-queries) and also [define](https://yourviews.mindstick.com/audio/1110/lifestyles-choices-that-define-our-lives) an example?

## Replies

### Reply by Ravi Vishwakarma

In LINQ **Select projection** operator is used for selecting data from collection or SQL Database. The select operator is the same as the SQL select clause operator.

## Syntax in C#

```
var result = from object-of-collection in collection
        select object-of-collection ;
```

```
var result = from s in student
        select new {new-variable-name = object-of-collection.member, ….. };
```

```
var result = collection.Select( argument => argument );
```

## \

**Example.**

```
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
 public static void Main()
 {
  List<Student> students = new List<Student>()
  {
  new Student() { StudentId = 1, Name = 'Asu', Marks = 500 },
  new Student() { StudentId = 2, Name = 'Shyam', Marks = 300 },
  new Student() { StudentId = 3, Name = 'Shriyam', Marks = 400 },
  new Student() { StudentId = 4, Name = 'Sunny', Marks = 550 },
  new Student() { StudentId = 5, Name = 'Ram', Marks = 600 },
  new Student() { StudentId = 6, Name = 'Krishna', Marks = 700 },
  new Student() { StudentId = 7, Name = 'Anupam', Marks = 550 }
  };
  // select projection using first sysntax
  var result1= from student in students
               select student ;
  Console.WriteLine('Using First Syntax :\n');
  result1.ToList().ForEach(item => Console.WriteLine('StudentName is {0}, ID is {1}, and Marks is {2}', item.Name, item.StudentId, item.Marks) );
  var result2 = from student in students
                select new {Name =student.Name,ID = student.StudentId,Marks = student.Marks };
  Console.WriteLine('\nUsing Second Syntax :\n');
  result2.ToList().ForEach(item => Console.WriteLine('StudentName is {0}, ID is {1}, and Marks is {2}', item.Name, item.ID, item.Marks) );
  var result3 = students.Select( student => student);
  Console.WriteLine('\nUsing Select method Syntax :\n');
  result3.ToList().ForEach(item => Console.WriteLine('StudentName is {0}, ID is {1}, and Marks is {2}', item.Name, item.StudentId, item.Marks) );
  Console.ReadLine();
 }
}
```

```
class Student
{
public int StudentId { get; set; }
public string Name { get; set; }
public int Marks { get; set; }
}
```

## Output

```
Using First Syntax :
StudentName is Asu, ID is 1, and Marks is 500
StudentName is Shyam, ID is 2, and Marks is 300
StudentName is Shriyam, ID is 3, and Marks is 400
StudentName is Sunny, ID is 4, and Marks is 550
StudentName is Ram, ID is 5, and Marks is 600
StudentName is Krishna, ID is 6, and Marks is 700
StudentName is Anupam, ID is 7, and Marks is 550
```

```
Using Second Syntax :
StudentName is Asu, ID is 1, and Marks is 500
StudentName is Shyam, ID is 2, and Marks is 300
StudentName is Shriyam, ID is 3, and Marks is 400
StudentName is Sunny, ID is 4, and Marks is 550
StudentName is Ram, ID is 5, and Marks is 600
StudentName is Krishna, ID is 6, and Marks is 700
StudentName is Anupam, ID is 7, and Marks is 550
```

```
Using Select method Syntax :
StudentName is Asu, ID is 1, and Marks is 500
StudentName is Shyam, ID is 2, and Marks is 300
StudentName is Shriyam, ID is 3, and Marks is 400
StudentName is Sunny, ID is 4, and Marks is 550
StudentName is Ram, ID is 5, and Marks is 600
StudentName is Krishna, ID is 6, and Marks is 700
StudentName is Anupam, ID is 7, and Marks is 550
```

\


---

Original Source: https://www.mindstick.com/forum/156758/how-to-use-select-projection-in-linq

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
