Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select 5, 10, 15, 20 and so on with LINQ

I want to display items in a dropdownlist like 5%, 10%, 15%, 20% until 100. Is there a way to bind an intelligent LINQ query to the datasource that will do this for me?

like image 618
Johan Leino Avatar asked Jun 11 '10 11:06

Johan Leino


1 Answers

You can use Enumerable.Range:

Enumerable.Range(1, 20).Select(x => 5 * x);

Or, in a more LINQ-like syntax:

from x in Enumerable.Range(1, 20)
select (x * 5);
like image 142
Dean Harding Avatar answered Oct 05 '22 08:10

Dean Harding