I am familiar with the Enumerable.Range method for generating an enumeration of values. But I would like something slightly different. I want to provide a min value, max value, and a number of desired points.
IE:
Method(double min, double max, int numberOfSteps)
taking
Method(0, 1000, 11);
would return
0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000
I figure for something like this, there must be a built-in method but my search hasn’t turned anything up. Am I missing something?
Other than the fact that you want the values to be
double, everything else can be done withEnumerable.Range. I don’t think there’s anything built-in to do what you want, but it’s trivial to implement on top ofEnumerable.Range:I’ve written that somewhat carefully so that you always end up with the final value. It does bork if you say you only want a single step though… you might want to guard against that and use
Enumerable.Repeat(min, 1)in that case.