An enthusiastic, adaptive, and fast-learning person with a broad and acute interest in the discovery of new innovative drugs, I particularly enjoy collaborating with scientists from different disciplines to develop new skills and solve new challenges.
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
Liked By
Write Answer
Give an example of LINQ Range Method.
Join MindStick Community
You have need login or register for voting of answers or question.
Ravi Vishwakarma
28-Sep-2021In 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
Example
Output