There is a bit of lack of clarity on whether you want to generate 'n' elements or whether you want to generate till the max value in the list.
Case 1 : If Generate till Max Value in List
public IEnumerable<int> Generate(int maxValue)
{
var currentValue = 0;
while(currentValue<maxValue)
{
currentValue += currentValue < 100 ? 10:100;
yield return currentValue;
}
}
You can now use the method as
var myList = new List<int>(new int[] { 12, 21, 30, 90, 100, 150, 404 });
var result = Generate(myList.Max());
Case 2 : When you want to generate N Elements.
var initialValue = 0;
var list = Enumerable.Range(1,totalNumberOfExpectedItems)
.Select(x=>
{
initialValue = initialValue < 100 ? initialValue + 10 : initialValue + 100;
return initialValue;
})
Enumerable.Range aids in generating sequence in a specified range
For totalNumberOfExpectedItems = 13
,
Output
10
20
30
40
50
60
70
80
90
100
200
300
400