---
title: "HOW to fetch Unique data from LINQ using the Distinct Method?"  
description: "HOW to fetch Unique data from LINQ using the Distinct Method?"  
author: "Ethan Karla"  
published: 2021-09-24  
updated: 2021-09-24  
canonical: https://www.mindstick.com/forum/156772/how-to-fetch-unique-data-from-linq-using-the-distinct-method  
category: "linq"  
tags: ["c#", "ado.net", "linq"]  
reading_time: 1 minute  

---

# HOW to fetch Unique data from LINQ using the Distinct Method?

HOW to [fetch](https://www.mindstick.com/forum/156159/what-is-google-fetch) [Unique](https://www.mindstick.com/blog/12870/how-to-be-unique-in-business) [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) from [LINQ](https://www.mindstick.com/articles/12007/language-integrated-query-linq-queries) using the [Distinct](https://www.mindstick.com/forum/159558/why-c-sharp-linq-distinct-doesn-t-work) [Method](https://www.mindstick.com/forum/166/webservice-method)?

## Replies

### Reply by Ravi Vishwakarma

In LINQ, the **Distinct** method or operator is used to get only distinct elements from the collection or list. In another word these distinct method doesn’t accept the duplicate elements, means remove the duplicate value make its single value.

## Syntax

```
collection1.Distinct ( collection2)
```

## Example

```
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
 public static void Main()
 {
  List<string> count1= new List<string>() { 'UK', 'Australia', 'India', 'USA', 'India', 'UAE', 'Canada', 'Uk', 'China', 'Pok' };
  // ignore the case
  //List<string> list = count1.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
  List<string> list = count1.Distinct().OrderBy( str => str).ToList();
  list.ForEach( country => Console.WriteLine(country) );
  Console.ReadLine();
 }
}
```

## Output

after using orderby() method result in ascending order

```
Australia
Canada
China
India
Pok
UAE
Uk
UK
USA
```


---

Original Source: https://www.mindstick.com/forum/156772/how-to-fetch-unique-data-from-linq-using-the-distinct-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
