I'm trying to convert a list of ints (-100, -80, -60, -40, -20, 0
) into a list of min max range pairs [-100, -80], [-80, -60], [-60,-40], [-40, -20], [-20, 0]
I have a C style forloop that does this but it's very inelegant. It relies on the exception to stop processing. There should be a way to use a LINQ or an IEnumerable query for this, right? I've been trying to think of a query that could satisfy this but I'm coming up with blanks.
var signalStrengthBuckets = new List<IMinMaxRange<int>>();
for (int i = 0; i < thresholdList.Count; i++)
{
try
{
signalStrengthBuckets.Add(
new MinMaxRange<int>(thresholdList[i], thresholdList[i + 1]));
}
catch (Exception e)
{
break;
}
}