---
title: "Give an example of LINQ Range Method."  
description: "Give an example of LINQ Range Method."  
author: "Ethan Karla"  
published: 2021-09-24  
updated: 2021-09-24  
canonical: https://www.mindstick.com/forum/156774/give-an-example-of-linq-range-method  
category: "linq"  
tags: ["c#", "ado.net", "linq"]  
reading_time: 1 minute  

---

# Give an example of LINQ Range Method.

Give an example of the [LINQ](https://www.mindstick.com/articles/12007/language-integrated-query-linq-queries) [Range](https://www.mindstick.com/articles/23243/complete-troubleshooting-tips-for-belkin-n300-range-extender-setup) Method.

## Replies

### Reply by Ravi Vishwakarma

In LINQ, the **Range()** method is used to generate the list of integers or numbers based on specified values of start index and end index.

## Syntax

```
Range(start_index, end_index)
```

## Example

```
using System;using System.Collections.Generic;using System.Linq;
public class Program{ public static void Main() {  List<int> range = Enumerable.Range(50,50).ToList();   Console.WriteLine('Prime List ');  range.ForEach(item => Console.Write('{0}', IsPrime(item) ? item+', ' : ''));
  Console.WriteLine('\b\b '); }
 public static bool IsPrime(int num){  for(int i=2;i<Math.Sqrt(num);i++)   if(num % i ==0 )    return false; return true;  }
}
```

## Output

```
Prime List 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
```

\


---

Original Source: https://www.mindstick.com/forum/156774/give-an-example-of-linq-range-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
